1 | protected class EListIterator<E1> extends EIterator<E1> implements ListIterator<E1> ↵ | | 1 | protected class EListIterator<E1> extends EIterator<E1> implements ListIterator<E1>↵
|
2 | {↵ | | 2 | {↵
|
3 | /**↵ | | 3 | /**↵
|
4 | * Creates an instance.↵ | | 4 | * Creates an instance.↵
|
5 | */↵ | | 5 | */↵
|
6 | public EListIterator() ↵ | | 6 | public EListIterator() ↵
|
7 | {↵ | | 7 | {↵
|
8 | super();↵ | | 8 | super();↵
|
9 | }↵ | | 9 | }↵
|
|
10 | /**↵ | | 10 | /**↵
|
11 | * Creates an instance advanced to the index.↵ | | 11 | * Creates an instance advanced to the index.↵
|
12 | * @param index the starting index.↵ | | 12 | * @param index the starting index.↵
|
13 | */↵ | | 13 | */↵
|
14 | public EListIterator(int index) ↵ | | 14 | public EListIterator(int index) ↵
|
15 | {↵ | | 15 | {↵
|
16 | cursor = index;↵ | | 16 | cursor = index;↵
|
17 | }↵ | | 17 | }↵
|
|
18 | /**↵ | | 18 | /**↵
|
19 | * Returns whether there are more objects for {@link #previous}.↵ | | 19 | * Returns whether there are more objects for {@link #previous}.↵
|
20 | * Returns whether there are more objects.↵ | | 20 | * Returns whether there are more objects.↵
|
21 | */↵ | | 21 | */↵
|
22 | public boolean hasPrevious() ↵ | | 22 | public boolean hasPrevious() ↵
|
23 | {↵ | | 23 | {↵
|
24 | return cursor != 0;↵ | | 24 | return cursor != 0;↵
|
25 | }↵ | | 25 | }↵
|
|
26 | /**↵ | | 26 | /**↵
|
27 | * Returns the previous object and advances the iterator.↵ | | 27 | * Returns the previous object and advances the iterator.↵
|
28 | * This implementation delegates to {@link #doPrevious doPrevious}.↵ | | 28 | * This implementation delegates to {@link #doPrevious doPrevious}.↵
|
29 | * @return the previous object.↵ | | 29 | * @return the previous object.↵
|
30 | * @exception NoSuchElementException if the iterator is done.↵ | | 30 | * @exception NoSuchElementException if the iterator is done.↵
|
31 | */↵ | | 31 | */↵
|
32 | @SuppressWarnings("unchecked")↵ | | 32 | @SuppressWarnings("unchecked")↵
|
33 | public E1 previous() ↵ | | 33 | public E1 previous() ↵
|
34 | {↵ | | 34 | {↵
|
35 | return (E1)doPrevious();↵ | | 35 | return (E1)doPrevious();↵
|
36 | }↵ | | 36 | }↵
|
|
37 | /**↵ | | 37 | /**↵
|
38 | * Returns the previous object and advances the iterator.↵ | | 38 | * Returns the previous object and advances the iterator.↵
|
39 | * This implementation delegates to {@link BasicEList#get get}.↵ | | 39 | * This implementation delegates to {@link DelegatingEList#get get}.↵
|
40 | * @return the previous object.↵ | | 40 | * @return the previous object.↵
|
41 | * @exception NoSuchElementException if the iterator is done.↵ | | 41 | * @exception NoSuchElementException if the iterator is done.↵
|
42 | */↵ | | 42 | */↵
|
43 | protected E doPrevious() ↵ | | 43 | protected E doPrevious() ↵
|
44 | {↵ | | 44 | {↵
|
45 | try ↵ | | 45 | try ↵
|
46 | {↵ | | 46 | {↵
|
47 | E previous = BasicEList.this.get(--cursor);↵ | | 47 | E previous = DelegatingEList.this.get(--cursor);↵
|
48 | checkModCount();↵ | | 48 | checkModCount();↵
|
49 | lastCursor = cursor;↵ | | 49 | lastCursor = cursor;↵
|
50 | return previous;↵ | | 50 | return previous;↵
|
51 | } ↵ | | 51 | } ↵
|
52 | catch (IndexOutOfBoundsException exception) ↵ | | 52 | catch (IndexOutOfBoundsException exception) ↵
|
53 | {↵ | | 53 | {↵
|
54 | checkModCount();↵ | | 54 | checkModCount();↵
|
55 | throw new NoSuchElementException();↵ | | 55 | throw new NoSuchElementException();↵
|
56 | }↵ | | 56 | }↵
|
57 | }↵ | | 57 | }↵
|
|
58 | /**↵ | | 58 | /**↵
|
59 | * Returns the index of the object that would be returned by calling {@link #next() next}.↵ | | 59 | * Returns the index of the object that would be returned by calling {@link #next() next}.↵
|
60 | * @return the index of the object that would be returned by calling <code>next</code>.↵ | | 60 | * @return the index of the object that would be returned by calling <code>next</code>.↵
|
61 | */↵ | | 61 | */↵
|
62 | public int nextIndex() ↵ | | 62 | public int nextIndex() ↵
|
63 | {↵ | | 63 | {↵
|
64 | return cursor;↵ | | 64 | return cursor;↵
|
65 | }↵ | | 65 | }↵
|
|
66 | /**↵ | | 66 | /**↵
|
67 | * Returns the index of the object that would be returned by calling {@link #previous previous}.↵ | | 67 | * Returns the index of the object that would be returned by calling {@link #previous previous}.↵
|
68 | * @return the index of the object that would be returned by calling <code>previous</code>.↵ | | 68 | * @return the index of the object that would be returned by calling <code>previous</code>.↵
|
69 | */↵ | | 69 | */↵
|
70 | public int previousIndex() ↵ | | 70 | public int previousIndex() ↵
|
71 | {↵ | | 71 | {↵
|
72 | return cursor - 1;↵ | | 72 | return cursor - 1;↵
|
73 | }↵ | | 73 | }↵
|
|
74 | /**↵ | | 74 | /**↵
|
75 | * Sets the object at the index of the last call to {@link #next() next} or {@link #previous previous}.↵ | | 75 | * Sets the object at the index of the last call to {@link #next() next} or {@link #previous previous}.↵
|
76 | * This implementation delegates to {@link BasicEList#set set}.↵ | | 76 | * This implementation delegates to {@link #doSet doSet}.↵
|
77 | * @param object the object to set.↵ | | 77 | * @param object the object to set.↵
|
78 | * @exception IllegalStateException↵ | | 78 | * @exception IllegalStateException↵
|
79 | * if <code>next</code> or <code>previous</code> have not yet been called,↵ | | 79 | * if <code>next</code> or <code>previous</code> have not yet been called,↵
|
80 | * or {@link #remove(Object) remove} or {@link #add add} have already been called ↵ | | 80 | * or {@link #remove() remove} or {@link #add add} have already been called ↵
|
81 | * after the last call to <code>next</code> or <code>previous</code>.↵ | | 81 | * after the last call to <code>next</code> or <code>previous</code>.↵
|
82 | */↵ | | 82 | */↵
|
83 | @SuppressWarnings("unchecked")↵ | | 83 | @SuppressWarnings("unchecked")↵
|
84 | public void set(E1 object) ↵ | | 84 | public void set(E1 object) ↵
|
85 | {↵ | | 85 | {↵
|
86 | doSet((E)object); ↵ | | 86 | doSet((E)object);↵
|
87 | }↵ | | 87 | }↵
|
|
88 | /**↵ | | 88 | /**↵
|
89 | * Sets the object at the index of the last call to {@link #next() next} or {@link #previous previous}.↵ | | 89 | * Sets the object at the index of the last call to {@link #next() next} or {@link #previous previous}.↵
|
90 | * This implementation delegates to {@link BasicEList#set set}.↵ | | 90 | * This implementation delegates to {@link DelegatingEList#set set}.↵
|
91 | * @param object the object to set.↵ | | 91 | * @param object the object to set.↵
|
92 | * @exception IllegalStateException↵ | | 92 | * @exception IllegalStateException↵
|
93 | * if <code>next</code> or <code>previous</code> have not yet been called,↵ | | 93 | * if <code>next</code> or <code>previous</code> have not yet been called,↵
|
94 | * or {@link #remove(Object) remove} or {@link #add add} have already been called ↵ | | 94 | * or {@link #remove() remove} or {@link #add add} have already been called ↵
|
95 | * after the last call to <code>next</code> or <code>previous</code>.↵ | | 95 | * after the last call to <code>next</code> or <code>previous</code>.↵
|
96 | */↵ | | 96 | */↵
|
97 | protected void doSet(E object) ↵ | | 97 | protected void doSet(E object) ↵
|
98 | {↵ | | 98 | {↵
|
99 | if (lastCursor == -1)↵ | | 99 | if (lastCursor == -1)↵
|
100 | {↵ | | 100 | {↵
|
101 | throw new IllegalStateException();↵ | | 101 | throw new IllegalStateException();↵
|
102 | }↵ | | 102 | }↵
|
103 | checkModCount();↵ | | 103 | checkModCount();↵
|
|
104 | try ↵ | | 104 | try ↵
|
105 | {↵ | | 105 | {↵
|
106 | BasicEList.this.set(lastCursor, object);↵ | | 106 | DelegatingEList.this.set(lastCursor, object);↵
|
107 | } ↵ | | 107 | } ↵
|
108 | catch (IndexOutOfBoundsException exception) ↵ | | 108 | catch (IndexOutOfBoundsException exception) ↵
|
109 | {↵ | | 109 | {↵
|
110 | throw new ConcurrentModificationException();↵ | | 110 | throw new ConcurrentModificationException();↵
|
111 | }↵ | | 111 | }↵
|
112 | }↵ | | 112 | }↵
|
|
113 | /**↵ | | 113 | /**↵
|
114 | * Adds the object at the {@link #next() next} index and advances the iterator past it.↵ | | 114 | * Adds the object at the {@link #next() next} index and advances the iterator past it.↵
|
115 | * This implementation delegates to {@link #doAdd(Object) doAdd(E)}.↵ | | 115 | * This implementation delegates to {@link #doAdd doAdd}.↵
|
116 | * @param object the object to add.↵ | | 116 | * @param object the object to add.↵
|
117 | */↵ | | 117 | */↵
|
118 | @SuppressWarnings("unchecked")↵ | | 118 | @SuppressWarnings("unchecked")↵
|
119 | public void add(E1 object) ↵ | | 119 | public void add(E1 object) ↵
|
120 | {↵ | | 120 | {↵
|
121 | doAdd((E)object);↵ | | 121 | doAdd((E)object);↵
|
122 | }↵ | | 122 | }↵
|
123 | ↵ | | |
|
124 | /**↵ | | 123 | /**↵
|
125 | * Adds the object at the {@link #next() next} index and advances the iterator past it.↵ | | 124 | * Adds the object at the {@link #next() next} index and advances the iterator past it.↵
|
126 | * This implementation delegates to {@link BasicEList#add(int, Object) add(int, E)}.↵ | | 125 | * This implementation delegates to {@link DelegatingEList#add(int, Object) add(int, Object)}.↵
|
127 | * @param object the object to add.↵ | | 126 | * @param object the object to add.↵
|
128 | */↵ | | 127 | */↵
|
129 | protected void doAdd(E object) ↵ | | 128 | protected void doAdd(E object) ↵
|
130 | {↵ | | 129 | {↵
|
131 | checkModCount();↵ | | 130 | checkModCount();↵
|
|
132 | try ↵ | | 131 | try ↵
|
133 | {↵ | | 132 | {↵
|
134 | BasicEList.this.add(cursor++, object);↵ | | 133 | DelegatingEList.this.add(cursor++, object);↵
|
135 | expectedModCount = modCount;↵ | | 134 | expectedModCount = modCount;↵
|
136 | lastCursor = -1;↵ | | 135 | lastCursor = -1;↵
|
137 | }↵ | | 136 | }↵
|
138 | catch (IndexOutOfBoundsException exception) ↵ | | 137 | catch (IndexOutOfBoundsException exception) ↵
|
139 | {↵ | | 138 | {↵
|
140 | throw new ConcurrentModificationException();↵ | | 139 | throw new ConcurrentModificationException();↵
|
141 | }↵ | | 140 | }↵
|
142 | }↵ | | 141 | }↵
|
143 | }↵ | | 142 | }↵
|
|
144 | /**↵ | | 143 | /**↵
|
145 | * Returns a read-only list iterator that does not {@link #resolve resolve} objects.↵ | | 144 | * Returns a read-only list iterator that does not {@link #resolve resolve} objects.↵
|
146 | * This implementation allocates a {@link NonResolvingEListIterator}.↵ | | 145 | * This implementation allocates a {@link NonResolvingEListIterator}.↵
|
147 | * @return a read-only list iterator that does not resolve objects.↵ | | 146 | * @return a read-only list iterator that does not resolve objects.↵
|
148 | */↵ | | 147 | */↵
|
149 | protected ListIterator<E> basicListIterator() ↵ | | 148 | protected ListIterator<E> basicListIterator() ↵
|
150 | {↵ | | 149 | {↵
|
151 | return new NonResolvingEListIterator<E>(); | | 150 | return new NonResolvingEListIterator<E>();
|