ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/Vector.java
(Generate patch)

Comparing jsr166/src/main/java/util/Vector.java (file contents):
Revision 1.10 by dl, Wed Apr 19 15:07:14 2006 UTC vs.
Revision 1.13 by jsr166, Sun May 28 23:36:29 2006 UTC

# Line 1 | Line 1
1   /*
2 < * @(#)Vector.java      1.103 05/12/06
2 > * %W% %E%
3   *
4   * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5   * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
# Line 43 | Line 43 | package java.util;
43   *
44   * <p>As of the Java 2 platform v1.2, this class was retrofitted to
45   * implement the {@link List} interface, making it a member of the
46 < * <a href="{@docRoot}/../guide/collections/index.html"> Java
46 > * <a href="{@docRoot}/../technotes/guides/collections/index.html"> Java
47   * Collections Framework</a>.  Unlike the new collection
48   * implementations, {@code Vector} is synchronized.
49   *
50   * @author  Lee Boynton
51   * @author  Jonathan Payne
52 < * @version 1.103, 12/06/05
52 > * @version %I%, %G%
53   * @see Collection
54   * @see List
55   * @see ArrayList
# Line 1194 | Line 1194 | public class Vector<E>
1194          final int parentOffset;           // index wrt parent
1195          int length;                       // length of sublist
1196  
1197 <        VectorSubList(Vector<E> base, AbstractList<E> parent, int baseOffset,
1197 >        VectorSubList(Vector<E> base, AbstractList<E> parent, int baseOffset,
1198                       int fromIndex, int toIndex) {
1199              if (fromIndex < 0)
1200                  throw new IndexOutOfBoundsException("fromIndex = " + fromIndex);
# Line 1216 | Line 1216 | public class Vector<E>
1216           * Returns an IndexOutOfBoundsException with nicer message
1217           */
1218          private IndexOutOfBoundsException indexError(int index) {
1219 <            return new IndexOutOfBoundsException("Index: " + index +
1219 >            return new IndexOutOfBoundsException("Index: " + index +
1220                                                   ", Size: " + length);
1221          }
1222  
# Line 1277 | Line 1277 | public class Vector<E>
1277              synchronized(base) {
1278                  if (base.modCount != modCount)
1279                      throw new ConcurrentModificationException();
1280 <                parent.removeRange(fromIndex + parentOffset,
1280 >                parent.removeRange(fromIndex + parentOffset,
1281                                     toIndex + parentOffset);
1282                  length -= (toIndex-fromIndex);
1283                  modCount = base.modCount;
# Line 1295 | Line 1295 | public class Vector<E>
1295                  int cSize = c.size();
1296                  if (cSize==0)
1297                      return false;
1298 <                
1298 >
1299                  if (base.modCount != modCount)
1300                      throw new ConcurrentModificationException();
1301                  parent.addAll(parentOffset + index, c);
# Line 1322 | Line 1322 | public class Vector<E>
1322          }
1323  
1324          public List<E> subList(int fromIndex, int toIndex) {
1325 <            return new VectorSubList(base, this, fromIndex + baseOffset,
1325 >            return new VectorSubList(base, this, fromIndex + baseOffset,
1326                                       fromIndex, toIndex);
1327          }
1328  
# Line 1331 | Line 1331 | public class Vector<E>
1331                  return new VectorSubListIterator(this, 0);
1332              }
1333          }
1334 <        
1334 >
1335          public synchronized ListIterator<E> listIterator() {
1336              synchronized(base) {
1337                  return new VectorSubListIterator(this, 0);
# Line 1358 | Line 1358 | public class Vector<E>
1358              int fence;                    // Upper bound on cursor
1359              int lastRet;                  // Index of returned element, or -1
1360              int expectedModCount;         // Expected modCount of base Vector
1361 <        
1361 >
1362              VectorSubListIterator(VectorSubList<E> list, int index) {
1363                  this.lastRet = -1;
1364                  this.cursor = index;
# Line 1368 | Line 1368 | public class Vector<E>
1368                  this.base = list.base;
1369                  this.expectedModCount = base.modCount;
1370              }
1371 <        
1371 >
1372              public boolean hasNext() {
1373                  return cursor < fence;
1374              }
1375 <        
1375 >
1376              public boolean hasPrevious() {
1377                  return cursor > 0;
1378              }
1379 <        
1379 >
1380              public int nextIndex() {
1381                  return cursor;
1382              }
1383 <        
1383 >
1384              public int previousIndex() {
1385                  return cursor - 1;
1386              }
1387 <        
1387 >
1388              public E next() {
1389                  int i = cursor;
1390                  if (cursor >= fence)
# Line 1394 | Line 1394 | public class Vector<E>
1394                  cursor = i + 1;
1395                  return (E)next;
1396              }
1397 <        
1397 >
1398              public E previous() {
1399                  int i = cursor - 1;
1400                  if (i < 0)
# Line 1404 | Line 1404 | public class Vector<E>
1404                  cursor = i;
1405                  return (E)prev;
1406              }
1407 <        
1407 >
1408              public void set(E e) {
1409                  if (lastRet < 0)
1410                      throw new IllegalStateException();
# Line 1417 | Line 1417 | public class Vector<E>
1417                      throw new ConcurrentModificationException();
1418                  }
1419              }
1420 <        
1420 >
1421              public void remove() {
1422                  int i = lastRet;
1423                  if (i < 0)
# Line 1435 | Line 1435 | public class Vector<E>
1435                      throw new ConcurrentModificationException();
1436                  }
1437              }
1438 <        
1438 >
1439              public void add(E e) {
1440                  if (base.modCount != expectedModCount)
1441                      throw new ConcurrentModificationException();
# Line 1455 | Line 1455 | public class Vector<E>
1455   }
1456  
1457  
1458 <    
1458 >

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines