DthingApi
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
java.util.AbstractList< E > Class Template Referenceabstract
Inheritance diagram for java.util.AbstractList< E >:
java.util.AbstractCollection< E > java.util.List< E > java.util.Collection< E > java.util.Collection< E > java.util.ArrayList< E > java.util.Vector< E >

Public Member Functions

void add (int location, E object)
 
boolean add (E object)
 
boolean addAll (int location, Collection<? extends E > collection)
 
void clear ()
 
boolean equals (Object object)
 
abstract E get (int location)
 
int hashCode ()
 
int indexOf (Object object)
 
Iterator< E > iterator ()
 
int lastIndexOf (Object object)
 
ListIterator< E > listIterator ()
 
ListIterator< E > listIterator (int location)
 
remove (int location)
 
set (int location, E object)
 
List< E > subList (int start, int end)
 
- Public Member Functions inherited from java.util.AbstractCollection< E >
boolean add (E object)
 
boolean addAll (Collection<? extends E > collection)
 
void clear ()
 
boolean contains (Object object)
 
boolean containsAll (Collection<?> collection)
 
boolean isEmpty ()
 
abstract Iterator< E > iterator ()
 
boolean remove (Object object)
 
boolean removeAll (Collection<?> collection)
 
boolean retainAll (Collection<?> collection)
 
abstract int size ()
 
Object [] toArray ()
 
String toString ()
 
- Public Member Functions inherited from java.util.List< E >
boolean addAll (Collection<? extends E > collection)
 
boolean contains (Object object)
 
boolean containsAll (Collection<?> collection)
 
boolean isEmpty ()
 
boolean remove (Object object)
 
boolean removeAll (Collection<?> collection)
 
boolean retainAll (Collection<?> collection)
 
int size ()
 
Object [] toArray ()
 

Protected Member Functions

 AbstractList ()
 
void removeRange (int start, int end)
 
- Protected Member Functions inherited from java.util.AbstractCollection< E >
 AbstractCollection ()
 

Protected Attributes

transient int modCount
 

Detailed Description

is an abstract implementation of the

List

interface, optimized for a backing store which supports random access. This implementation does not support adding or replacing. A subclass must implement the abstract methods

get()

and

size()

, and to create a modifiable

List

it's necessary to override the

add()

method that currently throws an

UnsupportedOperationException

.

Since
1.2

Constructor & Destructor Documentation

◆ AbstractList()

java.util.AbstractList< E >.AbstractList ( )
inlineprotected

Constructs a new instance of this AbstractList.

Member Function Documentation

◆ add() [1/2]

void java.util.AbstractList< E >.add ( int  location,
object 
)
inline

Inserts the specified object into this List at the specified location. The object is inserted before any previous element at the specified location. If the location is equal to the size of this List, the object is added at the end.

Concrete implementations that would like to support the add functionality must override this method.

Parameters
locationthe index at which to insert.
objectthe object to add.
Exceptions
UnsupportedOperationExceptionif adding to this List is not supported.
ClassCastExceptionif the class of the object is inappropriate for this List
IllegalArgumentExceptionif the object cannot be added to this List
IndexOutOfBoundsExceptionif
location < 0 || >= size()

Implements java.util.List< E >.

◆ add() [2/2]

boolean java.util.AbstractList< E >.add ( object)
inline

Adds the specified object at the end of this List.

Parameters
objectthe object to add
Returns
true
Exceptions
UnsupportedOperationExceptionif adding to this List is not supported
ClassCastExceptionif the class of the object is inappropriate for this List
IllegalArgumentExceptionif the object cannot be added to this List

Implements java.util.List< E >.

◆ addAll()

boolean java.util.AbstractList< E >.addAll ( int  location,
Collection<? extends E >  collection 
)
inline

Inserts the objects in the specified Collection at the specified location in this List. The objects are added in the order they are returned from the collection's iterator.

Parameters
locationthe index at which to insert.
collectionthe Collection of objects
Returns
true
if this List is modified,
false
otherwise.
Exceptions
UnsupportedOperationExceptionif adding to this list is not supported.
ClassCastExceptionif the class of an object is inappropriate for this list.
IllegalArgumentExceptionif an object cannot be added to this list.
IndexOutOfBoundsExceptionif
location < 0 || > size()

Implements java.util.List< E >.

◆ clear()

void java.util.AbstractList< E >.clear ( )
inline

Removes all elements from this list, leaving it empty.

Exceptions
UnsupportedOperationExceptionif removing from this list is not supported.
See also
List::isEmpty
List::size

Implements java.util.List< E >.

◆ equals()

boolean java.util.AbstractList< E >.equals ( Object  object)
inline

Compares the specified object to this list and return true if they are equal. Two lists are equal when they both contain the same objects in the same order.

Parameters
objectthe object to compare to this object.
Returns
true
if the specified object is equal to this list,
false
otherwise.
See also
hashCode

Implements java.util.List< E >.

◆ get()

abstract E java.util.AbstractList< E >.get ( int  location)
abstract

Returns the element at the specified location in this list.

Parameters
locationthe index of the element to return.
Returns
the element at the specified index.
Exceptions
IndexOutOfBoundsExceptionif
location < 0 || >= size()

Implements java.util.List< E >.

◆ hashCode()

int java.util.AbstractList< E >.hashCode ( )
inline

Returns the hash code of this list. The hash code is calculated by taking each element's hashcode into account.

Returns
the hash code.
See also
equals
List::hashCode()

Implements java.util.List< E >.

◆ indexOf()

int java.util.AbstractList< E >.indexOf ( Object  object)
inline

Searches this list for the specified object and returns the index of the first occurrence.

Parameters
objectthe object to search for.
Returns
the index of the first occurrence of the object, or -1 if it was not found.

Implements java.util.List< E >.

◆ iterator()

Iterator<E> java.util.AbstractList< E >.iterator ( )
inline

Returns an iterator on the elements of this list. The elements are iterated in the same order as they occur in the list.

Returns
an iterator on the elements of this list.
See also
Iterator

Implements java.util.List< E >.

◆ lastIndexOf()

int java.util.AbstractList< E >.lastIndexOf ( Object  object)
inline

Searches this list for the specified object and returns the index of the last occurrence.

Parameters
objectthe object to search for.
Returns
the index of the last occurrence of the object, or -1 if the object was not found.

Implements java.util.List< E >.

◆ listIterator() [1/2]

ListIterator<E> java.util.AbstractList< E >.listIterator ( )
inline

Returns a ListIterator on the elements of this list. The elements are iterated in the same order that they occur in the list.

Returns
a ListIterator on the elements of this list
See also
ListIterator

Implements java.util.List< E >.

◆ listIterator() [2/2]

ListIterator<E> java.util.AbstractList< E >.listIterator ( int  location)
inline

Returns a list iterator on the elements of this list. The elements are iterated in the same order as they occur in the list. The iteration starts at the specified location.

Parameters
locationthe index at which to start the iteration.
Returns
a ListIterator on the elements of this list.
Exceptions
IndexOutOfBoundsExceptionif
location < 0 || location > size()
See also
ListIterator

Implements java.util.List< E >.

◆ remove()

E java.util.AbstractList< E >.remove ( int  location)
inline

Removes the object at the specified location from this list.

Parameters
locationthe index of the object to remove.
Returns
the removed object.
Exceptions
UnsupportedOperationExceptionif removing from this list is not supported.
IndexOutOfBoundsExceptionif
location < 0 || >= size()

Implements java.util.List< E >.

◆ removeRange()

void java.util.AbstractList< E >.removeRange ( int  start,
int  end 
)
inlineprotected

Removes the objects in the specified range from the start to the end index minus one.

Parameters
startthe index at which to start removing.
endthe index after the last element to remove.
Exceptions
UnsupportedOperationExceptionif removing from this list is not supported.
IndexOutOfBoundsExceptionif
start < 0
or
start >= size()
.

◆ set()

E java.util.AbstractList< E >.set ( int  location,
object 
)
inline

Replaces the element at the specified location in this list with the specified object.

Parameters
locationthe index at which to put the specified object.
objectthe object to add.
Returns
the previous element at the index.
Exceptions
UnsupportedOperationExceptionif replacing elements in this list is not supported.
ClassCastExceptionif the class of an object is inappropriate for this list.
IllegalArgumentExceptionif an object cannot be added to this list.
IndexOutOfBoundsExceptionif
location < 0 || >= size()

Implements java.util.List< E >.

◆ subList()

List<E> java.util.AbstractList< E >.subList ( int  start,
int  end 
)
inline

Returns a part of consecutive elements of this list as a view. The returned view will be of zero length if start equals end. Any change that occurs in the returned subList will be reflected to the original list, and vice-versa. All the supported optional operations by the original list will also be supported by this subList.

This method can be used as a handy method to do some operations on a sub range of the original list, for example

list.subList(from, to).clear();

If the original list is modified in other ways than through the returned subList, the behavior of the returned subList becomes undefined.

The returned subList is a subclass of AbstractList. The subclass stores offset, size of itself, and modCount of the original list. If the original list implements RandomAccess interface, the returned subList also implements RandomAccess interface.

The subList's set(int, Object), get(int), add(int, Object), remove(int), addAll(int, Collection) and removeRange(int, int) methods first check the bounds, adjust offsets and then call the corresponding methods of the original AbstractList. addAll(Collection c) method of the returned subList calls the original addAll(offset + size, c).

The listIterator(int) method of the subList wraps the original list iterator. The iterator() method of the subList invokes the original listIterator() method, and the size() method merely returns the size of the subList.

All methods will throw a ConcurrentModificationException if the modCount of the original list is not equal to the expected value.

Parameters
startstart index of the subList (inclusive).
endend index of the subList, (exclusive).
Returns
a subList view of this list starting from
start
(inclusive), and ending with
end
(exclusive)
Exceptions
IndexOutOfBoundsExceptionif (start < 0 || end > size())
IllegalArgumentExceptionif (start > end)

Implements java.util.List< E >.

Member Data Documentation

◆ modCount

transient int java.util.AbstractList< E >.modCount
protected

A counter for changes to the list.


The documentation for this class was generated from the following file: