Moyosoft Products | Services | Download | Contact us    
JavaDocPlus
Products  >  JavaDocPlus  >  Online demo    


Latest release




Get a FREE license !
(Special offer, time limited)

Review JavaDocPlus on your blog and we'll give you a free license.

Open source projects licenced under LGPL, EPL, ASL, BSD or MIT can also obtain a free license.

Contact us to check if your project/blog is eligible.

Online demo
JavaDocPlus Demo  |  Show in full page mode
   
Overview  |  
Classic JavaDoc

Class AbstractList

java.lang.Objectjava.util.AbstractCollectionjava.util.AbstractList

Implemented Interfaces:
Direct Known Subclasses:

public abstract class AbstractList extends AbstractCollection implements List

This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a "random access" data store (such as an array). For sequential access data (such as a linked list), AbstractSequentialList should be used in preference to this class.

To implement an unmodifiable list, the programmer needs only to extend this class and provide implementations for the get(int index) and size() methods.

To implement a modifiable list, the programmer must additionally override the set(int index, Object element) method (which otherwise throws an UnsupportedOperationException. If the list is variable-size the programmer must additionally override the add(int index, Object element) and remove(int index) methods.

The programmer should generally provide a void (no argument) and collection constructor, as per the recommendation in the Collection interface specification.

Unlike the other abstract collection implementations, the programmer does not have to provide an iterator implementation; the iterator and list iterator are implemented by this class, on top the "random access" methods: get(int index), set(int index, Object element), set(int index, Object element), add(int index, Object element) and remove(int index).

The documentation for each non-abstract methods in this class describes its implementation in detail. Each of these methods may be overridden if the collection being implemented admits a more efficient implementation.

This class is a member of the Java Collections Framework.

Author:
Josh BlochNeal Gafter

Version:
1.37, 01/18/03

See Also:
Collection, List, AbstractSequentialList, AbstractCollection

Since:
1.2

Fields

transient int
modCount
The number of times this list has been structurally modified. Structural modifications are those that change the size of the list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results. This field is used by the iterator and list iterator i ... more >

Constructors

protected
AbstractList ()
Sole constructor. (For invocation by subclass constructors, typically implicit.)

Methods

boolean
add (Object o)
Appends the specified element to the end of this List (optional operation). This implementation calls add(size(), o). Note that this implementation throws an UnsupportedOperationException unless add(int, Object) is overridden.
void
add (int index, Object element)
Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices). This implementation always throws an UnsupportedOperationException.
boolean
addAll (int index, Collection c)
Inserts all of the elements in the specified collection into this list at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list i ... more >
void
clear ()
Removes all of the elements from this collection (optional operation). The collection will be empty after this call returns (unless it throws an exception). This implementation calls removeRange(0, size()). Note that this implementation throws an UnsupportedOperationException unle ... more >
boolean
equals (Object o)
Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : ... more >
abstract Object
get (int index)
Returns the element at the specified position in this list.
int
hashCode ()
Returns the hash code value for this list. This implementation uses exactly the code that is used to define the list hash function in the documentation for the List.hashCode method.
int
indexOf (Object o)
Returns the index in this list of the first occurence of the specified element, or -1 if the list does not contain this element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index. This implementation fir ... more >
iterator ()
Returns an iterator over the elements in this list in proper sequence. This implementation returns a straightforward implementation of the iterator interface, relying on the backing list's size(), get(int), and remove(int) methods. Note that the iterator returned by this method w ... more >
int
lastIndexOf (Object o)
Returns the index in this list of the last occurence of the specified element, or -1 if the list does not contain this element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index. This implementation fir ... more >
listIterator ()
Returns an iterator of the elements in this list (in proper sequence). This implementation returns listIterator(0).
listIterator (int index)
Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in the list. The specified index indicates the first element that would be returned by an initial call to the next method. An initial call to the previous method would return ... more >
remove (int index)
Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list. This implementation always throws an UnsupportedOperationException.
void
removeRange (int fromIndex, int toIndex)
Removes from this list all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive. Shifts any succeeding elements to the left (reduces their index). This call shortens the ArrayList by (toIndex - fromIndex) elements. (If toIndex==fromIndex, this operation ... more >
set (int index, Object element)
Replaces the element at the specified position in this list with the specified element (optional operation). This implementation always throws an UnsupportedOperationException.
subList (int fromIndex, int toIndex)
Returns a view of the portion of this list between fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so changes in the returned list are reflected in this list, and vice-versa. Th ... more >

Inherited methods

Community comments



Powered by JavaDocPlus