67 |
* @return The object at the given index |
* @return The object at the given index |
68 |
* |
* |
69 |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
70 |
* outside the bounds of the list <code>[0, size())</code> |
* outside the bounds of the list <code>[0, size())</code> |
71 |
*/ |
*/ |
72 |
public Object elementAt(int index) |
public Object elementAt(int index) |
73 |
{ |
{ |
90 |
* @param element The element to search for |
* @param element The element to search for |
91 |
* |
* |
92 |
* @return The first index in the list at which an object |
* @return The first index in the list at which an object |
93 |
* <code>obj</code> exists such that <code>obj.equals(element)</code> is |
* <code>obj</code> exists such that <code>obj.equals(element)</code> is |
94 |
* <code>true</code>; if no such object exists, the method returns |
* <code>true</code>; if no such object exists, the method returns |
95 |
* <code>-1</code> |
* <code>-1</code> |
96 |
*/ |
*/ |
97 |
public int indexOf(Object element) |
public int indexOf(Object element) |
98 |
{ |
{ |
107 |
* @param startIndex The index to begin searching at |
* @param startIndex The index to begin searching at |
108 |
* |
* |
109 |
* @return The first index in the list, greater than or equal to |
* @return The first index in the list, greater than or equal to |
110 |
* <code>startIndex</code>, at which an object <code>obj</code> exists |
* <code>startIndex</code>, at which an object <code>obj</code> exists |
111 |
* such that <code>obj.equals(element)</code> is <code>true</code>; if no |
* such that <code>obj.equals(element)</code> is <code>true</code>; if no |
112 |
* such object exists, the method returns <code>-1</code> |
* such object exists, the method returns <code>-1</code> |
113 |
*/ |
*/ |
114 |
public int indexOf(Object element, int startIndex) |
public int indexOf(Object element, int startIndex) |
115 |
{ |
{ |
122 |
* @param element The element to search for |
* @param element The element to search for |
123 |
* |
* |
124 |
* @return The last index in the list at which an object |
* @return The last index in the list at which an object |
125 |
* <code>obj</code> exists such that <code>obj.equals(element)</code> is |
* <code>obj</code> exists such that <code>obj.equals(element)</code> is |
126 |
* <code>true</code>; if no such object exists, the method returns |
* <code>true</code>; if no such object exists, the method returns |
127 |
* <code>-1</code> |
* <code>-1</code> |
128 |
*/ |
*/ |
129 |
public int lastIndexOf(Object element) |
public int lastIndexOf(Object element) |
130 |
{ |
{ |
139 |
* @param endIndex The index to finish searching at |
* @param endIndex The index to finish searching at |
140 |
* |
* |
141 |
* @return The last index in the list, less than to or equal to |
* @return The last index in the list, less than to or equal to |
142 |
* <code>endIndexIndex</code>, at which an object <code>obj</code> exists |
* <code>endIndexIndex</code>, at which an object <code>obj</code> exists |
143 |
* such that <code>obj.equals(element)</code> is <code>true</code>; if no |
* such that <code>obj.equals(element)</code> is <code>true</code>; if no |
144 |
* such object exists, the method returns <code>-1</code> |
* such object exists, the method returns <code>-1</code> |
145 |
*/ |
*/ |
146 |
public int lastIndexOf(Object element, int endIndex) |
public int lastIndexOf(Object element, int endIndex) |
147 |
{ |
{ |
156 |
* @return The list value at the provided index |
* @return The list value at the provided index |
157 |
* |
* |
158 |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
159 |
* outside the bounds of the list <code>[0, size())</code> |
* outside the bounds of the list <code>[0, size())</code> |
160 |
*/ |
*/ |
161 |
public Object get(int index) |
public Object get(int index) |
162 |
{ |
{ |
172 |
* @return The value previously held at the specified index |
* @return The value previously held at the specified index |
173 |
* |
* |
174 |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
175 |
* outside the bounds of the list <code>[0, size())</code> |
* outside the bounds of the list <code>[0, size())</code> |
176 |
*/ |
*/ |
177 |
public Object set(int index, Object element) |
public Object set(int index, Object element) |
178 |
{ |
{ |
193 |
* @param element The element to insert at the index |
* @param element The element to insert at the index |
194 |
* |
* |
195 |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
196 |
* outside the bounds <code>[0, size()]</code> |
* outside the bounds <code>[0, size()]</code> |
197 |
*/ |
*/ |
198 |
public void add(int index, Object element) |
public void add(int index, Object element) |
199 |
{ |
{ |
228 |
* Gets an array containing the elements of the list. |
* Gets an array containing the elements of the list. |
229 |
* |
* |
230 |
* @return An array of the objects in the list, in the order they occur |
* @return An array of the objects in the list, in the order they occur |
231 |
* in the list |
* in the list |
232 |
*/ |
*/ |
233 |
public Object[] toArray() |
public Object[] toArray() |
234 |
{ |
{ |
241 |
* @param element The element to search for |
* @param element The element to search for |
242 |
* |
* |
243 |
* @return <code>true</code> if <code>element</code> is a member of the |
* @return <code>true</code> if <code>element</code> is a member of the |
244 |
* list, otherwise <code>false</code> |
* list, otherwise <code>false</code> |
245 |
*/ |
*/ |
246 |
public boolean contains(Object element) |
public boolean contains(Object element) |
247 |
{ |
{ |
255 |
* @param array The array to copy the list into |
* @param array The array to copy the list into |
256 |
* |
* |
257 |
* @throws IndexOutOfBoundsException if the array is too small to hold the |
* @throws IndexOutOfBoundsException if the array is too small to hold the |
258 |
* elements of the list |
* elements of the list |
259 |
*/ |
*/ |
260 |
public void copyInto(Object[] array) |
public void copyInto(Object[] array) |
261 |
{ |
{ |
283 |
* @return The value at the index, which has been removed from the list |
* @return The value at the index, which has been removed from the list |
284 |
* |
* |
285 |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
286 |
* outside the bounds of the list <code>[0, size())</code> |
* outside the bounds of the list <code>[0, size())</code> |
287 |
*/ |
*/ |
288 |
public Object remove(int index) |
public Object remove(int index) |
289 |
{ |
{ |
297 |
* Determines whether the list is empty. |
* Determines whether the list is empty. |
298 |
* |
* |
299 |
* @return <code>true</code> if the list is empty, otherwise |
* @return <code>true</code> if the list is empty, otherwise |
300 |
* <code>false</code> |
* <code>false</code> |
301 |
*/ |
*/ |
302 |
public boolean isEmpty() |
public boolean isEmpty() |
303 |
{ |
{ |
348 |
{ |
{ |
349 |
int oldSize = elements.size(); |
int oldSize = elements.size(); |
350 |
elements.setSize(size); |
elements.setSize(size); |
351 |
if (oldSize < size) |
if (oldSize < size) |
352 |
{ |
{ |
353 |
fireIntervalAdded(this, oldSize, size - 1); |
fireIntervalAdded(this, oldSize, size - 1); |
354 |
} |
} |
355 |
else if (oldSize > size) |
else if (oldSize > size) |
356 |
{ |
{ |
357 |
this.fireIntervalRemoved(this, size, oldSize - 1); |
this.fireIntervalRemoved(this, size, oldSize - 1); |
358 |
} |
} |
359 |
} |
} |
360 |
|
|
361 |
/** |
/** |
396 |
* @param index The list index at which to set a value |
* @param index The list index at which to set a value |
397 |
* |
* |
398 |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
399 |
* outside the bounds of the list <code>[0, size())</code> |
* outside the bounds of the list <code>[0, size())</code> |
400 |
*/ |
*/ |
401 |
public void setElementAt(Object element, int index) |
public void setElementAt(Object element, int index) |
402 |
{ |
{ |
410 |
* @param index The index of the element to remove |
* @param index The index of the element to remove |
411 |
* |
* |
412 |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
413 |
* outside the bounds of the list <code>[0, size())</code> |
* outside the bounds of the list <code>[0, size())</code> |
414 |
*/ |
*/ |
415 |
public void removeElementAt(int index) |
public void removeElementAt(int index) |
416 |
{ |
{ |
429 |
* @param index The index to insert the element at |
* @param index The index to insert the element at |
430 |
* |
* |
431 |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
432 |
* outside the bounds <code>[0, size()]</code> |
* outside the bounds <code>[0, size()]</code> |
433 |
*/ |
*/ |
434 |
public void insertElementAt(Object element, int index) |
public void insertElementAt(Object element, int index) |
435 |
{ |
{ |
444 |
* @param element The element to remove |
* @param element The element to remove |
445 |
* |
* |
446 |
* @return <code>true</code> if the element existed in the list (and was |
* @return <code>true</code> if the element existed in the list (and was |
447 |
* removed), <code>false</code> otherwise |
* removed), <code>false</code> otherwise |
448 |
*/ |
*/ |
449 |
public boolean removeElement(Object element) |
public boolean removeElement(Object element) |
450 |
{ |
{ |
481 |
* @param endIndex The last index in the range to remove |
* @param endIndex The last index in the range to remove |
482 |
* |
* |
483 |
* @throws ArrayIndexOutOfBoundsException if either index is outside the |
* @throws ArrayIndexOutOfBoundsException if either index is outside the |
484 |
* valid range of indices for this list <code>[0, size())</code> |
* valid range of indices for this list <code>[0, size())</code> |
485 |
* @throws IllegalArgumentException if <code>startIndex > endIndex</code> |
* @throws IllegalArgumentException if <code>startIndex > endIndex</code> |
486 |
*/ |
*/ |
487 |
public void removeRange(int startIndex, int endIndex) |
public void removeRange(int startIndex, int endIndex) |
488 |
{ |
{ |
512 |
* @return The list value at the provided index |
* @return The list value at the provided index |
513 |
* |
* |
514 |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
* @throws ArrayIndexOutOfBoundsException If the provided index is |
515 |
* outside the bounds of the list <code>[0, size())</code> |
* outside the bounds of the list <code>[0, size())</code> |
516 |
*/ |
*/ |
517 |
public Object getElementAt(int index) |
public Object getElementAt(int index) |
518 |
{ |
{ |