Vector.java (ensureCapacity): Don't increment modCount.

2000-11-27  Bryce McKinlay  <bryce@albatross.co.nz>

	* java/util/Vector.java (ensureCapacity): Don't increment modCount.
	(addElement): Don't increment elementCount twice. Doh.
	* java/util/ArrayList.java (add): Only call ensureCapacity if the
	array needs to be expanded.
	(addAll): Ditto.
	* java/util/Collections.java (UnmodifiableCollection): Implement
	toString().
	(UnmodifiableList): Throw UnsupportedOperationException from
	modification methods. Set `l' from the one-parameter constructor.
	(UnmodifiableMap): Implement toString().
	(SynchronizedCollection): Ditto.
	(SynchronizedList): Set `l' from the one-parameter constructor.
	(SynchronizedSortedSet): Set `ss' from the one-parameter constructor.
	(SynchronizedMap): Implement toString().

From-SVN: r37785
This commit is contained in:
Bryce McKinlay 2000-11-27 08:30:26 +00:00 committed by Bryce McKinlay
parent 27e2564ac8
commit f24dbacf85
4 changed files with 55 additions and 39 deletions

View file

@ -178,7 +178,6 @@ public class Vector extends AbstractList
*/
public synchronized void ensureCapacity(int minCapacity)
{
modCount++;
if (elementData.length >= minCapacity)
return;
@ -459,7 +458,7 @@ public class Vector extends AbstractList
public synchronized void addElement(Object obj)
{
if (elementCount == elementData.length)
ensureCapacity(++elementCount);
ensureCapacity(elementCount + 1);
modCount++;
elementData[elementCount++] = obj;
}