716 |
*/ |
*/ |
717 |
public synchronized boolean removeAll(Collection c) |
public synchronized boolean removeAll(Collection c) |
718 |
{ |
{ |
719 |
|
if (c == null) |
720 |
|
throw new NullPointerException(); |
721 |
|
|
722 |
int i; |
int i; |
723 |
int j; |
int j; |
724 |
for (i = 0; i < elementCount; i++) |
for (i = 0; i < elementCount; i++) |
745 |
*/ |
*/ |
746 |
public synchronized boolean retainAll(Collection c) |
public synchronized boolean retainAll(Collection c) |
747 |
{ |
{ |
748 |
|
if (c == null) |
749 |
|
throw new NullPointerException(); |
750 |
|
|
751 |
int i; |
int i; |
752 |
int j; |
int j; |
753 |
for (i = 0; i < elementCount; i++) |
for (i = 0; i < elementCount; i++) |
785 |
ensureCapacity(elementCount + csize); |
ensureCapacity(elementCount + csize); |
786 |
int end = index + csize; |
int end = index + csize; |
787 |
if (elementCount > 0 && index != elementCount) |
if (elementCount > 0 && index != elementCount) |
788 |
System.arraycopy(elementData, index, elementData, end, csize); |
System.arraycopy(elementData, index, |
789 |
|
elementData, end, elementCount - index); |
790 |
elementCount += csize; |
elementCount += csize; |
791 |
for ( ; index < end; index++) |
for ( ; index < end; index++) |
792 |
elementData[index] = itr.next(); |
elementData[index] = itr.next(); |
859 |
|
|
860 |
/** |
/** |
861 |
* Removes a range of elements from this list. |
* Removes a range of elements from this list. |
862 |
|
* Does nothing when toIndex is equal to fromIndex. |
863 |
* |
* |
864 |
* @param fromIndex the index to start deleting from (inclusive) |
* @param fromIndex the index to start deleting from (inclusive) |
865 |
* @param toIndex the index to delete up to (exclusive) |
* @param toIndex the index to delete up to (exclusive) |
866 |
|
* @throws IndexOutOfBoundsException if fromIndex > toIndex |
867 |
*/ |
*/ |
868 |
// This does not need to be synchronized, because it is only called through |
// This does not need to be synchronized, because it is only called through |
869 |
// clear() of a sublist, and clear() had already synchronized. |
// clear() of a sublist, and clear() had already synchronized. |
870 |
protected void removeRange(int fromIndex, int toIndex) |
protected void removeRange(int fromIndex, int toIndex) |
871 |
{ |
{ |
872 |
if (fromIndex != toIndex) |
int change = toIndex - fromIndex; |
873 |
|
if (change > 0) |
874 |
{ |
{ |
875 |
modCount++; |
modCount++; |
876 |
System.arraycopy(elementData, toIndex, elementData, fromIndex, |
System.arraycopy(elementData, toIndex, elementData, fromIndex, |
877 |
elementCount - toIndex); |
elementCount - toIndex); |
878 |
int save = elementCount; |
int save = elementCount; |
879 |
elementCount -= toIndex - fromIndex; |
elementCount -= change; |
880 |
Arrays.fill(elementData, elementCount, save, null); |
Arrays.fill(elementData, elementCount, save, null); |
881 |
} |
} |
882 |
|
else if (change < 0) |
883 |
|
throw new IndexOutOfBoundsException(); |
884 |
} |
} |
885 |
|
|
886 |
/** |
/** |