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.11 by jsr166, Thu Apr 20 21:49:36 2006 UTC

# 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