| protected transient int modCount = 0; |
| public Iterator iterator() { return new Itr(); } |
| int expectedModCount = modCount; |
| public boolean hasNext() { return cursor != size(); } |
| public Object next() { try { Object next = get(cursor); checkForComodification(); lastRet = cursor++; return next; } catch(IndexOutOfBoundsException e) { checkForComodification(); throw new NoSuchElementException(); } } |
| final void checkForComodification() { if (modCount != expectedModCount) throw new ConcurrentModificationException(); } |
| private static final long serialVersionUID = 8683452581122892189L; private transient Object elementData[]; private int size; |
| private synchronized void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { // Write out element count, and any hidden stuff s.defaultWriteObject(); // Write out array length s.writeInt(elementData.length); // Write out all elements in the proper order. for (int i=0; i<size; i++) s.writeObject(elementData[i]); } |
| private synchronized void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in size, and any hidden stuff s.defaultReadObject(); // Read in array length and allocate array int arrayLength = s.readInt(); elementData = new Object[arrayLength]; // Read in all elements in the proper order. for (int i=0; i<size; i++) elementData[i] = s.readObject(); } |
关注此文的读者还看过: