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

Comparing jsr166/src/main/java/util/ArrayList.java (file contents):
Revision 1.3 by jsr166, Sat Nov 26 03:03:49 2005 UTC vs.
Revision 1.4 by jsr166, Sat Nov 26 03:12:10 2005 UTC

# Line 146 | Line 146 | public class ArrayList<E> extends Abstra
146          }
147          initFromConcurrentlyMutating(c);
148      }
149 <    
149 >
150      private void initFromConcurrentlyMutating(Collection<? extends E> c) {
151          elementData = c.toArray();
152          size = elementData.length;
# Line 154 | Line 154 | public class ArrayList<E> extends Abstra
154          if (elementData.getClass() != Object[].class)
155              elementData = Arrays.copyOf(elementData, size, Object[].class);
156      }
157 <    
157 >
158      private final static Object UNALLOCATED = new Object();
159 <    
159 >
160      /**
161       * Trims the capacity of this <tt>ArrayList</tt> instance to be the
162       * list's current size.  An application can use this operation to minimize
# Line 190 | Line 190 | public class ArrayList<E> extends Abstra
190      private void growArray(int minCapacity) {
191          int oldCapacity = elementData.length;
192          // Double size if small; else grow by 50%
193 <        int newCapacity = ((oldCapacity < 64)?
193 >        int newCapacity = ((oldCapacity < 64)?
194                             (oldCapacity * 2):
195                             ((oldCapacity * 3)/2 + 1));
196          if (newCapacity < minCapacity)
# Line 341 | Line 341 | public class ArrayList<E> extends Abstra
341  
342      // Positional Access Operations
343  
344 <    /**
345 <     * Create and return an appropriate exception for indexing errors
344 >    /**
345 >     * Create and return an appropriate exception for indexing errors
346       */
347      private static IndexOutOfBoundsException rangeException(int i, int s) {
348          return new IndexOutOfBoundsException("Index: " + i + ", Size: " + s);
# Line 436 | Line 436 | public class ArrayList<E> extends Abstra
436          Object oldValue = elementData[index];
437          int numMoved = s - index;
438          if (numMoved > 0)
439 <            System.arraycopy(elementData, index+1, elementData, index,
439 >            System.arraycopy(elementData, index+1, elementData, index,
440                               numMoved);
441          elementData[s] = null; // forget removed element
442          return (E)oldValue;
# Line 652 | Line 652 | public class ArrayList<E> extends Abstra
652              throw new IndexOutOfBoundsException("Index: "+index);
653          return new ArrayListIterator(index);
654      }
655 <
655 >
656      /**
657       * Returns an iterator over the elements in this list in proper sequence.
658       *
# Line 663 | Line 663 | public class ArrayList<E> extends Abstra
663      }
664  
665      /**
666 <     * A streamlined version of AbstractList.Itr
666 >     * A streamlined version of AbstractList.Itr
667       */
668      final class ArrayListIterator implements ListIterator<E> {
669          int cursor;           // index of next element to return;
# Line 701 | Line 701 | public class ArrayList<E> extends Abstra
701                          lastRet = i;
702                          cursor = i + 1;
703                          return e;
704 <                    } catch (IndexOutOfBoundsException fallthrough) {
704 >                    } catch (IndexOutOfBoundsException fallthrough) {
705                      }
706                  }
707              }
# Line 720 | Line 720 | public class ArrayList<E> extends Abstra
720                          lastRet = i;
721                          cursor = i;
722                          return e;
723 <                    } catch (IndexOutOfBoundsException fallthrough) {
723 >                    } catch (IndexOutOfBoundsException fallthrough) {
724                      }
725                  }
726              }
# Line 732 | Line 732 | public class ArrayList<E> extends Abstra
732          public void remove() {
733              if (lastRet < 0)
734                  throw new IllegalStateException();
735 <            if (modCount != expectedModCount)
735 >            if (modCount != expectedModCount)
736                  throw new ConcurrentModificationException();
737              ArrayList.this.remove(lastRet);
738              if (lastRet < cursor)
# Line 744 | Line 744 | public class ArrayList<E> extends Abstra
744          public void set(E e) {
745              if (lastRet < 0)
746                  throw new IllegalStateException();
747 <            if (modCount != expectedModCount)
747 >            if (modCount != expectedModCount)
748                  throw new ConcurrentModificationException();
749              ArrayList.this.set(lastRet, e);
750              expectedModCount = modCount;
751          }
752  
753          public void add(E e) {
754 <            if (modCount != expectedModCount)
754 >            if (modCount != expectedModCount)
755                  throw new ConcurrentModificationException();
756              ArrayList.this.add(cursor++, e);
757              lastRet = -1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines