/[classpath]/classpath/java/util/Vector.java
ViewVC logotype

Diff of /classpath/java/util/Vector.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by tromey, Wed Jan 23 00:06:10 2002 UTC revision 1.19 by mark, Sun Apr 7 07:39:13 2002 UTC
# Line 716  public class Vector extends AbstractList Line 716  public class Vector extends AbstractList
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++)
# Line 742  public class Vector extends AbstractList Line 745  public class Vector extends AbstractList
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++)
# Line 779  public class Vector extends AbstractList Line 785  public class Vector extends AbstractList
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();
# Line 852  public class Vector extends AbstractList Line 859  public class Vector extends AbstractList
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 &gt; 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    /**    /**

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26