Improved build.xml
[vimdoclet.git] / sample / java.util.List.txt
blobc9267272f7ba697cb347321aa86754506d036b84
1 *java.util.List* *List* An ordered collection (also known as a sequence).
3 public interface interface List
5   implements |java.util.Collection|
7 |java.util.List_Description|
8 |java.util.List_Fields|
9 |java.util.List_Constructors|
10 |java.util.List_Methods|
12 ================================================================================
14 *java.util.List_Methods*
15 |java.util.List.add(E)|Appends the specified element to the end of this list (o
16 |java.util.List.add(int,E)|Inserts the specified element at the specified posit
17 |java.util.List.addAll(Collection)|Appends all of the elements in the specified
18 |java.util.List.addAll(int,Collection)|Inserts all of the elements in the speci
19 |java.util.List.clear()|Removes all of the elements from this list (optional op
20 |java.util.List.contains(Object)|Returns true if this list contains the specifi
21 |java.util.List.containsAll(Collection)|Returns true if this list contains all 
22 |java.util.List.equals(Object)|Compares the specified object with this list for
23 |java.util.List.get(int)|Returns the element at the specified position in this 
24 |java.util.List.hashCode()|Returns the hash code value for this list.
25 |java.util.List.indexOf(Object)|Returns the index in this list of the first occ
26 |java.util.List.isEmpty()|Returns true if this list contains no elements.
27 |java.util.List.iterator()|Returns an iterator over the elements in this list i
28 |java.util.List.lastIndexOf(Object)|Returns the index in this list of the last 
29 |java.util.List.listIterator()|Returns a list iterator of the elements in this 
30 |java.util.List.listIterator(int)|Returns a list iterator of the elements in th
31 |java.util.List.remove(int)|Removes the element at the specified position in th
32 |java.util.List.remove(Object)|Removes the first occurrence in this list of the
33 |java.util.List.removeAll(Collection)|Removes from this list all the elements t
34 |java.util.List.retainAll(Collection)|Retains only the elements in this list th
35 |java.util.List.set(int,E)|Replaces the element at the specified position in th
36 |java.util.List.size()|Returns the number of elements in this list.
37 |java.util.List.subList(int,int)|Returns a view of the portion of this list bet
38 |java.util.List.toArray()|Returns an array containing all of the elements in th
39 |java.util.List.toArray(T[])|Returns an array containing all of the elements in
41 *java.util.List_Description*
43 An ordered collection (also known as a sequence). The user of this interface 
44 has precise control over where in the list each element is inserted. The user 
45 can access elements by their integer index (position in the list), and search 
46 for elements in the list. 
48 Unlike sets, lists typically allow duplicate elements. More formally, lists 
49 typically allow pairs of elements e1 and e2 such that e1.equals(e2), and they 
50 typically allow multiple null elements if they allow null elements at all. It 
51 is not inconceivable that someone might wish to implement a list that prohibits 
52 duplicates, by throwing runtime exceptions when the user attempts to insert 
53 them, but we expect this usage to be rare. 
55 The List interface places additional stipulations, beyond those specified in 
56 the Collection interface, on the contracts of the iterator, add, remove, 
57 equals, and hashCode methods. Declarations for other inherited methods are also 
58 included here for convenience. 
60 The List interface provides four methods for positional (indexed) access to 
61 list elements. Lists (like Java arrays) are zero based. Note that these 
62 operations may execute in time proportional to the index value for some 
63 implementations (the LinkedList class, for example). Thus, iterating over the 
64 elements in a list is typically preferable to indexing through it if the caller 
65 does not know the implementation. 
67 The List interface provides a special iterator, called a ListIterator, that 
68 allows element insertion and replacement, and bidirectional access in addition 
69 to the normal operations that the Iterator interface provides. A method is 
70 provided to obtain a list iterator that starts at a specified position in the 
71 list. 
73 The List interface provides two methods to search for a specified object. From 
74 a performance standpoint, these methods should be used with caution. In many 
75 implementations they will perform costly linear searches. 
77 The List interface provides two methods to efficiently insert and remove 
78 multiple elements at an arbitrary point in the list. 
80 Note: While it is permissible for lists to contain themselves as elements, 
81 extreme caution is advised: the equals and hashCode methods are no longer well 
82 defined on a such a list. 
84 Some list implementations have restrictions on the elements that they may 
85 contain. For example, some implementations prohibit null elements, and some 
86 have restrictions on the types of their elements. Attempting to add an 
87 ineligible element throws an unchecked exception, typically 
88 NullPointerException or ClassCastException. Attempting to query the presence of 
89 an ineligible element may throw an exception, or it may simply return false; 
90 some implementations will exhibit the former behavior and some will exhibit the 
91 latter. More generally, attempting an operation on an ineligible element whose 
92 completion would not result in the insertion of an ineligible element into the 
93 list may throw an exception or it may succeed, at the option of the 
94 implementation. Such exceptions are marked as "optional" in the specification 
95 for this interface. 
97 This interface is a member of the <a href="/../guide/collections/index.html"> 
98 Java Collections Framework. 
101 *java.util.List.add(E)*
103 public boolean add(java.lang.Object o)
105 Appends the specified element to the end of this list (optional operation). 
107 Lists that support this operation may place limitations on what elements may be 
108 added to this list. In particular, some lists will refuse to add null elements, 
109 and others will impose restrictions on the type of elements that may be added. 
110 List classes should clearly specify in their documentation any restrictions on 
111 what elements may be added. 
113     o - element to be appended to this list. 
115     Returns: true (as per the general contract of the Collection.add method). 
116 *java.util.List.add(int,E)*
118 public void add(
119   int index,
120   java.lang.Object element)
122 Inserts the specified element at the specified position in this list (optional 
123 operation). Shifts the element currently at that position (if any) and any 
124 subsequent elements to the right (adds one to their indices). 
126     index - index at which the specified element is to be inserted. 
127     element - element to be inserted. 
129 *java.util.List.addAll(Collection)*
131 public boolean addAll(java.util.Collection c)
133 Appends all of the elements in the specified collection to the end of this 
134 list, in the order that they are returned by the specified collection's 
135 iterator (optional operation). The behavior of this operation is unspecified if 
136 the specified collection is modified while the operation is in progress. (Note 
137 that this will occur if the specified collection is this list, and it's 
138 nonempty.) 
140     c - collection whose elements are to be added to this list. 
142     Returns: true if this list changed as a result of the call. 
143 *java.util.List.addAll(int,Collection)*
145 public boolean addAll(
146   int index,
147   java.util.Collection c)
149 Inserts all of the elements in the specified collection into this list at the 
150 specified position (optional operation). Shifts the element currently at that 
151 position (if any) and any subsequent elements to the right (increases their 
152 indices). The new elements will appear in this list in the order that they are 
153 returned by the specified collection's iterator. The behavior of this operation 
154 is unspecified if the specified collection is modified while the operation is 
155 in progress. (Note that this will occur if the specified collection is this 
156 list, and it's nonempty.) 
158     index - index at which to insert first element from the specified collection. 
159     c - elements to be inserted into this list. 
161     Returns: true if this list changed as a result of the call. 
162 *java.util.List.clear()*
164 public void clear()
166 Removes all of the elements from this list (optional operation). This list will 
167 be empty after this call returns (unless it throws an exception). 
170 *java.util.List.contains(Object)*
172 public boolean contains(java.lang.Object o)
174 Returns true if this list contains the specified element. More formally, 
175 returns true if and only if this list contains at least one element e such that 
176 (o==null?e==null:o.equals(e)). 
178     o - element whose presence in this list is to be tested. 
180     Returns: true if this list contains the specified element. 
181 *java.util.List.containsAll(Collection)*
183 public boolean containsAll(java.util.Collection c)
185 Returns true if this list contains all of the elements of the specified 
186 collection. 
188     c - collection to be checked for containment in this list. 
190     Returns: true if this list contains all of the elements of the specified collection. 
191 *java.util.List.equals(Object)*
193 public boolean equals(java.lang.Object o)
195 Compares the specified object with this list for equality. Returns true if and 
196 only if the specified object is also a list, both lists have the same size, and 
197 all corresponding pairs of elements in the two lists are equal. (Two elements 
198 e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, 
199 two lists are defined to be equal if they contain the same elements in the same 
200 order. This definition ensures that the equals method works properly across 
201 different implementations of the List interface. 
203     o - the object to be compared for equality with this list. 
205     Returns: true if the specified object is equal to this list. 
206 *java.util.List.get(int)*
208 public |java.lang.Object| get(int index)
210 Returns the element at the specified position in this list. 
212     index - index of element to return. 
214     Returns: the element at the specified position in this list. 
215 *java.util.List.hashCode()*
217 public int hashCode()
219 Returns the hash code value for this list. The hash code of a list is defined 
220 to be the result of the following calculation: 
222 hashCode = 1; Iterator i = list.iterator(); while (i.hasNext()) { Object obj = 
223 i.next(); hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode()); } 
225 This ensures that list1.equals(list2) implies that 
226 list1.hashCode()==list2.hashCode() for any two lists, list1 and list2, as 
227 required by the general contract of Object.hashCode. 
230     Returns: the hash code value for this list. 
231 *java.util.List.indexOf(Object)*
233 public int indexOf(java.lang.Object o)
235 Returns the index in this list of the first occurrence of the specified 
236 element, or -1 if this list does not contain this element. More formally, 
237 returns the lowest index i such that (o==null ? get(i)==null : 
238 o.equals(get(i))), or -1 if there is no such index. 
240     o - element to search for. 
242     Returns: the index in this list of the first occurrence of the specified element, or -1 
243              if this list does not contain this element. 
244 *java.util.List.isEmpty()*
246 public boolean isEmpty()
248 Returns true if this list contains no elements. 
251     Returns: true if this list contains no elements. 
252 *java.util.List.iterator()*
254 public |java.util.Iterator| iterator()
256 Returns an iterator over the elements in this list in proper sequence. 
259     Returns: an iterator over the elements in this list in proper sequence. 
260 *java.util.List.lastIndexOf(Object)*
262 public int lastIndexOf(java.lang.Object o)
264 Returns the index in this list of the last occurrence of the specified element, 
265 or -1 if this list does not contain this element. More formally, returns the 
266 highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if 
267 there is no such index. 
269     o - element to search for. 
271     Returns: the index in this list of the last occurrence of the specified element, or -1 
272              if this list does not contain this element. 
273 *java.util.List.listIterator()*
275 public |java.util.ListIterator| listIterator()
277 Returns a list iterator of the elements in this list (in proper sequence). 
280     Returns: a list iterator of the elements in this list (in proper sequence). 
281 *java.util.List.listIterator(int)*
283 public |java.util.ListIterator| listIterator(int index)
285 Returns a list iterator of the elements in this list (in proper sequence), 
286 starting at the specified position in this list. The specified index indicates 
287 the first element that would be returned by an initial call to the next method. 
288 An initial call to the previous method would return the element with the 
289 specified index minus one. 
291     index - index of first element to be returned from the list iterator (by a call to the 
292        next method). 
294     Returns: a list iterator of the elements in this list (in proper sequence), starting at 
295              the specified position in this list. 
296 *java.util.List.remove(int)*
298 public |java.lang.Object| remove(int index)
300 Removes the element at the specified position in this list (optional 
301 operation). Shifts any subsequent elements to the left (subtracts one from 
302 their indices). Returns the element that was removed from the list. 
304     index - the index of the element to removed. 
306     Returns: the element previously at the specified position. 
307 *java.util.List.remove(Object)*
309 public boolean remove(java.lang.Object o)
311 Removes the first occurrence in this list of the specified element (optional 
312 operation). If this list does not contain the element, it is unchanged. More 
313 formally, removes the element with the lowest index i such that (o==null ? 
314 get(i)==null : o.equals(get(i))) (if such an element exists). 
316     o - element to be removed from this list, if present. 
318     Returns: true if this list contained the specified element. 
319 *java.util.List.removeAll(Collection)*
321 public boolean removeAll(java.util.Collection c)
323 Removes from this list all the elements that are contained in the specified 
324 collection (optional operation). 
326     c - collection that defines which elements will be removed from this list. 
328     Returns: true if this list changed as a result of the call. 
329 *java.util.List.retainAll(Collection)*
331 public boolean retainAll(java.util.Collection c)
333 Retains only the elements in this list that are contained in the specified 
334 collection (optional operation). In other words, removes from this list all the 
335 elements that are not contained in the specified collection. 
337     c - collection that defines which elements this set will retain. 
339     Returns: true if this list changed as a result of the call. 
340 *java.util.List.set(int,E)*
342 public |java.lang.Object| set(
343   int index,
344   java.lang.Object element)
346 Replaces the element at the specified position in this list with the specified 
347 element (optional operation). 
349     index - index of element to replace. 
350     element - element to be stored at the specified position. 
352     Returns: the element previously at the specified position. 
353 *java.util.List.size()*
355 public int size()
357 Returns the number of elements in this list. If this list contains more than 
358 Integer.MAX_VALUE elements, returns Integer.MAX_VALUE. 
361     Returns: the number of elements in this list. 
362 *java.util.List.subList(int,int)*
364 public |java.util.List| subList(
365   int fromIndex,
366   int toIndex)
368 Returns a view of the portion of this list between the specified fromIndex, 
369 inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the 
370 returned list is empty.) The returned list is backed by this list, so 
371 non-structural changes in the returned list are reflected in this list, and 
372 vice-versa. The returned list supports all of the optional list operations 
373 supported by this list. 
375 This method eliminates the need for explicit range operations (of the sort that 
376 commonly exist for arrays). Any operation that expects a list can be used as a 
377 range operation by passing a subList view instead of a whole list. For example, 
378 the following idiom removes a range of elements from a list: 
380 list.subList(from, to).clear(); 
382 Similar idioms may be constructed for indexOf and lastIndexOf, and all of the 
383 algorithms in the Collections class can be applied to a subList. 
385 The semantics of the list returned by this method become undefined if the 
386 backing list (i.e., this list) is structurally modified in any way other than 
387 via the returned list. (Structural modifications are those that change the size 
388 of this list, or otherwise perturb it in such a fashion that iterations in 
389 progress may yield incorrect results.) 
391     fromIndex - low endpoint (inclusive) of the subList. 
392     toIndex - high endpoint (exclusive) of the subList. 
394     Returns: a view of the specified range within this list. 
395 *java.util.List.toArray()*
397 public |java.lang.Object| toArray()
399 Returns an array containing all of the elements in this list in proper 
400 sequence. Obeys the general contract of the Collection.toArray method. 
403     Returns: an array containing all of the elements in this list in proper sequence. 
404 *java.util.List.toArray(T[])*
406 public |java.lang.Object| toArray(java.lang.Object[] a)
408 Returns an array containing all of the elements in this list in proper 
409 sequence; the runtime type of the returned array is that of the specified 
410 array. Obeys the general contract of the Collection.toArray(Object[]) method. 
412     a - the array into which the elements of this list are to be stored, if it is big 
413        enough; otherwise, a new array of the same runtime type is allocated for 
414        this purpose. 
416     Returns: an array containing the elements of this list.