fixed some formatting typos
[vimdoclet.git] / sample / java.util.AbstractList.txt
blobd7c736280f97ce5b5faed7549343bc8386917fe6
1 *java.util.AbstractList* *AbstractList* This class provides a skeletal implement
3 public abstract class AbstractList<E>
4   extends    |java.util.AbstractCollection|
5   implements |java.util.List|
7 |java.util.AbstractList_Description|
8 |java.util.AbstractList_Fields|
9 |java.util.AbstractList_Constructors|
10 |java.util.AbstractList_Methods|
12 ================================================================================
14 *java.util.AbstractList_Fields*
15 |int_java.util.AbstractList.modCount|
17 *java.util.AbstractList_Constructors*
18 |java.util.AbstractList()|Sole constructor.
20 *java.util.AbstractList_Methods*
21 |java.util.AbstractList.add(E)|Appends the specified element to the end of this
22 |java.util.AbstractList.add(int,E)|
23 |java.util.AbstractList.addAll(int,Collection<?extendsE>)|
24 |java.util.AbstractList.clear()|Removes all of the elements from this list (opt
25 |java.util.AbstractList.equals(Object)|Compares the specified object with this 
26 |java.util.AbstractList.get(int)|
27 |java.util.AbstractList.hashCode()|Returns the hash code value for this list.
28 |java.util.AbstractList.indexOf(Object)|
29 |java.util.AbstractList.iterator()|Returns an iterator over the elements in thi
30 |java.util.AbstractList.lastIndexOf(Object)|
31 |java.util.AbstractList.listIterator()|
32 |java.util.AbstractList.listIterator(int)|
33 |java.util.AbstractList.remove(int)|
34 |java.util.AbstractList.removeRange(int,int)|Removes from this list all of the 
35 |java.util.AbstractList.set(int,E)|
36 |java.util.AbstractList.subList(int,int)|
38 *java.util.AbstractList_Description*
40 This class provides a skeletal implementation of the (|java.util.List|) 
41 interface to minimize the effort required to implement this interface backed by 
42 a "random access" data store (such as an array). For sequential access data 
43 (such as a linked list), (|java.util.AbstractSequentialList|) should be used in 
44 preference to this class. 
46 To implement an unmodifiable list, the programmer needs only to extend this 
47 class and provide implementations for the (|java.util.AbstractList|) and 
48 size()(|java.util.List|) methods. 
50 To implement a modifiable list, the programmer must additionally override the 
51 set(int, E)(|java.util.AbstractList|) method (which otherwise throws 
52 anUnsupportedOperationException). If the list is variable-size the programmer 
53 must additionally override the add(int, E)(|java.util.AbstractList|) and 
54 (|java.util.AbstractList|) methods. 
56 The programmer should generally provide a void (no argument) and collection 
57 constructor, as per the recommendation in the (|java.util.Collection|) 
58 interface specification. 
60 Unlike the other abstract collection implementations, the programmer does not 
61 have to provide an iterator implementation; the iterator and list iterator are 
62 implemented by this class, on top of the "random access" methods: 
63 (|java.util.AbstractList|) , set(int, E)(|java.util.AbstractList|) , add(int, 
64 E)(|java.util.AbstractList|) and (|java.util.AbstractList|) . 
66 The documentation for each non-abstract method in this class describes its 
67 implementation in detail. Each of these methods may be overridden if the 
68 collection being implemented admits a more efficient implementation. 
70 This class is a member of the <a 
71 href="/../technotes/guides/collections/index.html"> Java Collections Framework. 
75 *int_java.util.AbstractList.modCount*
77 The number of times this list has been structurally modified. Structural 
78 modifications are those that change the size of the list, or otherwise perturb 
79 it in such a fashion that iterations in progress may yield incorrect results. 
81 This field is used by the iterator and list iterator implementation returned by 
82 theiteratorandlistIteratormethods. If the value of this field changes 
83 unexpectedly, the iterator (or list iterator) will throw 
84 aConcurrentModificationExceptionin response to 
85 thenext,remove,previous,setoraddoperations. This provides fail-fast behavior, 
86 rather than non-deterministic behavior in the face of concurrent modification 
87 during iteration. 
89 Use of this field by subclasses is optional. If a subclass wishes to provide 
90 fail-fast iterators (and list iterators), then it merely has to increment this 
91 field in itsadd(int, E)andremove(int)methods (and any other methods that it 
92 overrides that result in structural modifications to the list). A single call 
93 toadd(int, E)orremove(int)must add no more than one to this field, or the 
94 iterators (and list iterators) will throw 
95 bogusConcurrentModificationExceptions. If an implementation does not wish to 
96 provide fail-fast iterators, this field may be ignored. 
100 *java.util.AbstractList()*
102 protected AbstractList()
104 Sole constructor. (For invocation by subclass constructors, typically 
105 implicit.) 
108 *java.util.AbstractList.add(E)*
110 public boolean add(E e)
112 Appends the specified element to the end of this list (optional operation). 
114 Lists that support this operation may place limitations on what elements may be 
115 added to this list. In particular, some lists will refuse to add null elements, 
116 and others will impose restrictions on the type of elements that may be added. 
117 List classes should clearly specify in their documentation any restrictions on 
118 what elements may be added. 
120 This implementation callsadd(size(), e). 
122 Note that this implementation throws anUnsupportedOperationExceptionunless 
123 add(int, E)(|java.util.AbstractList|) is overridden. 
126     e - element to be appended to this list 
128     Returns: {@code true} (as specified by {@link Collection#add}) 
130 *java.util.AbstractList.add(int,E)*
132 public void add(
133   int index,
134   E element)
136 This implementation always throws anUnsupportedOperationException. 
140 *java.util.AbstractList.addAll(int,Collection<?extendsE>)*
142 public boolean addAll(
143   int index,
144   java.util.Collection<? extends E> c)
146 This implementation gets an iterator over the specified collection and iterates 
147 over it, inserting the elements obtained from the iterator into this list at 
148 the appropriate position, one at a time, usingadd(int, E). Many implementations 
149 will override this method for efficiency. 
151 Note that this implementation throws anUnsupportedOperationExceptionunless 
152 add(int, E)(|java.util.AbstractList|) is overridden. 
156 *java.util.AbstractList.clear()*
158 public void clear()
160 Removes all of the elements from this list (optional operation). The list will 
161 be empty after this call returns. 
163 This implementation callsremoveRange(0, size()). 
165 Note that this implementation throws 
166 anUnsupportedOperationExceptionunlessremove(int index)orremoveRange(int 
167 fromIndex, int toIndex)is overridden. 
171 *java.util.AbstractList.equals(Object)*
173 public boolean equals(java.lang.Object o)
175 Compares the specified object with this list for equality. Returnstrueif and 
176 only if the specified object is also a list, both lists have the same size, and 
177 all corresponding pairs of elements in the two lists are equal. (Two 
178 elementse1ande2are equal if(e1==null ? e2==null : e1.equals(e2)).) In other 
179 words, two lists are defined to be equal if they contain the same elements in 
180 the same order. 
182 This implementation first checks if the specified object is this list. If so, 
183 it returnstrue; if not, it checks if the specified object is a list. If not, it 
184 returnsfalse; if so, it iterates over both lists, comparing corresponding pairs 
185 of elements. If any comparison returnsfalse, this method returnsfalse. If 
186 either iterator runs out of elements before the other it returnsfalse(as the 
187 lists are of unequal length); otherwise it returnstruewhen the iterations 
188 complete. 
191     o - the object to be compared for equality with this list 
193     Returns: {@code true} if the specified object is equal to this list 
195 *java.util.AbstractList.get(int)*
197 public abstract |E| get(int index)
203 *java.util.AbstractList.hashCode()*
205 public int hashCode()
207 Returns the hash code value for this list. 
209 This implementation uses exactly the code that is used to define the list hash 
210 function in the documentation for the (|java.util.List|) method. 
214     Returns: the hash code value for this list 
216 *java.util.AbstractList.indexOf(Object)*
218 public int indexOf(java.lang.Object o)
220 This implementation first gets a list iterator (withlistIterator()). Then, it 
221 iterates over the list until the specified element is found or the end of the 
222 list is reached. 
226 *java.util.AbstractList.iterator()*
228 public |java.util.Iterator|<E> iterator()
230 Returns an iterator over the elements in this list in proper sequence. 
232 This implementation returns a straightforward implementation of the iterator 
233 interface, relying on the backing list'ssize(),get(int), andremove(int)methods. 
235 Note that the iterator returned by this method will throw 
236 anUnsupportedOperationExceptionin response to itsremovemethod unless the 
237 list'sremove(int)method is overridden. 
239 This implementation can be made to throw runtime exceptions in the face of 
240 concurrent modification, as described in the specification for the 
241 (protected)modCountfield. 
245     Returns: an iterator over the elements in this list in proper sequence 
247 *java.util.AbstractList.lastIndexOf(Object)*
249 public int lastIndexOf(java.lang.Object o)
251 This implementation first gets a list iterator that points to the end of the 
252 list (withlistIterator(size())). Then, it iterates backwards over the list 
253 until the specified element is found, or the beginning of the list is reached. 
257 *java.util.AbstractList.listIterator()*
259 public |java.util.ListIterator|<E> listIterator()
261 This implementation returnslistIterator(0). 
265 *java.util.AbstractList.listIterator(int)*
267 public |java.util.ListIterator|<E> listIterator(int index)
269 This implementation returns a straightforward implementation of 
270 theListIteratorinterface that extends the implementation of 
271 theIteratorinterface returned by theiterator()method. 
272 TheListIteratorimplementation relies on the backing list'sget(int),set(int, 
273 E),add(int, E)andremove(int)methods. 
275 Note that the list iterator returned by this implementation will throw 
276 anUnsupportedOperationExceptionin response to itsremove,setandaddmethods unless 
277 the list'sremove(int),set(int, E), andadd(int, E)methods are overridden. 
279 This implementation can be made to throw runtime exceptions in the face of 
280 concurrent modification, as described in the specification for the 
281 (protected)modCountfield. 
285 *java.util.AbstractList.remove(int)*
287 public |E| remove(int index)
289 This implementation always throws anUnsupportedOperationException. 
293 *java.util.AbstractList.removeRange(int,int)*
295 protected void removeRange(
296   int fromIndex,
297   int toIndex)
299 Removes from this list all of the elements whose index is betweenfromIndex, 
300 inclusive, andtoIndex, exclusive. Shifts any succeeding elements to the left 
301 (reduces their index). This call shortens the ArrayList by(toIndex - 
302 fromIndex)elements. (IftoIndex==fromIndex, this operation has no effect.) 
304 This method is called by theclearoperation on this list and its subLists. 
305 Overriding this method to take advantage of the internals of the list 
306 implementation can substantially improve the performance of theclearoperation 
307 on this list and its subLists. 
309 This implementation gets a list iterator positioned beforefromIndex, and 
310 repeatedly callsListIterator.nextfollowed byListIterator.removeuntil the entire 
311 range has been removed. Note: ifListIterator.removerequires linear time, this 
312 implementation requires quadratic time. 
315     fromIndex - index of first element to be removed 
316     toIndex - index after last element to be removed 
318 *java.util.AbstractList.set(int,E)*
320 public |E| set(
321   int index,
322   E element)
324 This implementation always throws anUnsupportedOperationException. 
328 *java.util.AbstractList.subList(int,int)*
330 public |java.util.List|<E> subList(
331   int fromIndex,
332   int toIndex)
334 This implementation returns a list that subclassesAbstractList. The subclass 
335 stores, in private fields, the offset of the subList within the backing list, 
336 the size of the subList (which can change over its lifetime), and the 
337 expectedmodCountvalue of the backing list. There are two variants of the 
338 subclass, one of which implementsRandomAccess. If this list 
339 implementsRandomAccessthe returned list will be an instance of the subclass 
340 that implementsRandomAccess. 
342 The subclass'sset(int, E),get(int),add(int, E),remove(int),addAll(int, 
343 Collection)andremoveRange(int, int)methods all delegate to the corresponding 
344 methods on the backing abstract list, after bounds-checking the index and 
345 adjusting for the offset. TheaddAll(Collection c)method merely 
346 returnsaddAll(size, c). 
348 ThelistIterator(int)method returns a "wrapper object" over a list iterator on 
349 the backing list, which is created with the corresponding method on the backing 
350 list. Theiteratormethod merely returnslistIterator(), and thesizemethod merely 
351 returns the subclass'ssizefield. 
353 All methods first check to see if the actualmodCountof the backing list is 
354 equal to its expected value, and throw aConcurrentModificationExceptionif it is 
355 not.