DthingApi
Public Member Functions | List of all members
java.util.List< E > Interface Template Reference
Inheritance diagram for java.util.List< E >:
java.util.Collection< E > java.util.AbstractList< E > java.util.ArrayList< E > java.util.Vector< 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)
 
boolean addAll (Collection<? extends E > collection)
 
void clear ()
 
boolean contains (Object object)
 
boolean containsAll (Collection<?> collection)
 
boolean equals (Object object)
 
get (int location)
 
int hashCode ()
 
int indexOf (Object object)
 
boolean isEmpty ()
 
Iterator< E > iterator ()
 
int lastIndexOf (Object object)
 
ListIterator< E > listIterator ()
 
ListIterator< E > listIterator (int location)
 
remove (int location)
 
boolean remove (Object object)
 
boolean removeAll (Collection<?> collection)
 
boolean retainAll (Collection<?> collection)
 
set (int location, E object)
 
int size ()
 
List< E > subList (int start, int end)
 
Object [] toArray ()
 

Detailed Description

A

List

is a collection which maintains an ordering for its elements. Every element in the

List

has an index. Each element can thus be accessed by its index, with the first index being zero. Normally,

List

s allow duplicate elements, as compared to Sets, where elements have to be unique.

Member Function Documentation

◆ add() [1/2]

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

Inserts the specified object into this

List

at the specified location. The object is inserted before the current element at the specified location. If the location is equal to the size of this

List

, the object is added at the end. If the location is smaller than the size of this

List

, then all elements beyond the specified location are moved by one position towards the end of the

List

.

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 || location > size()

Implemented in java.util.AbstractList< E >, java.util.ArrayList< E >, and java.util.Vector< E >.

◆ add() [2/2]

boolean java.util.List< E >.add ( object)

Adds the specified object at the end of this

List

.

Parameters
objectthe object to add.
Returns
always 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.Collection< E >.

Implemented in java.util.AbstractList< E >, java.util.Vector< E >, and java.util.ArrayList< E >.

◆ addAll() [1/2]

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

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 to be inserted.
Returns
true if this
List
has been modified through the insertion, false otherwise (i.e. if the passed collection was empty).
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()

Implemented in java.util.AbstractList< E >, java.util.ArrayList< E >, and java.util.Vector< E >.

◆ addAll() [2/2]

boolean java.util.List< E >.addAll ( Collection<? extends E >  collection)

Adds the objects in the specified collection to the end of this

List

. The objects are added in the order in which they are returned from the collection's iterator.

Parameters
collectionthe collection of objects.
Returns
true
if this
List
is modified,
false
otherwise (i.e. if the passed collection was empty).
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
.

Implements java.util.Collection< E >.

Implemented in java.util.Vector< E >, and java.util.ArrayList< E >.

◆ clear()

void java.util.List< E >.clear ( )

Removes all elements from this

List

, leaving it empty.

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

Implements java.util.Collection< E >.

Implemented in java.util.AbstractList< E >, java.util.ArrayList< E >, and java.util.Vector< E >.

◆ contains()

boolean java.util.List< E >.contains ( Object  object)

Tests whether this

List

contains the specified object.

Parameters
objectthe object to search for.
Returns
true
if object is an element of this
List
,
false
otherwise

Implements java.util.Collection< E >.

Implemented in java.util.ArrayList< E >, and java.util.Vector< E >.

◆ containsAll()

boolean java.util.List< E >.containsAll ( Collection<?>  collection)

Tests whether this

List

contains all objects contained in the specified collection.

Parameters
collectionthe collection of objects
Returns
true
if all objects in the specified collection are elements of this
List
,
false
otherwise.

Implements java.util.Collection< E >.

Implemented in java.util.Vector< E >.

◆ equals()

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

Compares the given object with the

List

, and returns true if they represent the same object using a class specific comparison. For

List

s, this means that they contain the same elements in exactly the same order.

Parameters
objectthe object to compare with this object.
Returns
boolean
true
if the object is the same as this object, and
false
if it is different from this object.
See also
hashCode

Implements java.util.Collection< E >.

Implemented in java.util.ArrayList< E >, java.util.AbstractList< E >, and java.util.Vector< E >.

◆ get()

E java.util.List< E >.get ( int  location)

Returns the element at the specified location in this

List

.

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

Implemented in java.util.AbstractList< E >, java.util.Vector< E >, and java.util.ArrayList< E >.

◆ hashCode()

int java.util.List< E >.hashCode ( )

Returns the hash code for this

List

. It is calculated by taking each element' hashcode and its position in the

List

into account.

Returns
the hash code of the
List
.

Implements java.util.Collection< E >.

Implemented in java.util.ArrayList< E >, java.util.AbstractList< E >, and java.util.Vector< E >.

◆ indexOf()

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

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 the object was not found.

Implemented in java.util.AbstractList< E >, java.util.Vector< E >, and java.util.ArrayList< E >.

◆ isEmpty()

boolean java.util.List< E >.isEmpty ( )

Returns whether this

List

contains no elements.

Returns
true
if this
List
has no elements,
false
otherwise.
See also
size

Implements java.util.Collection< E >.

Implemented in java.util.Vector< E >, and java.util.ArrayList< E >.

◆ iterator()

Iterator<E> java.util.List< E >.iterator ( )

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.Collection< E >.

Implemented in java.util.AbstractList< E >, and java.util.ArrayList< E >.

◆ lastIndexOf()

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

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.

Implemented in java.util.Vector< E >, java.util.AbstractList< E >, and java.util.ArrayList< E >.

◆ listIterator() [1/2]

ListIterator<E> java.util.List< E >.listIterator ( )

Returns a

List

iterator on the elements of this

List

. The elements are iterated in the same order that they occur in the

List

.

Returns
a
List
iterator on the elements of this
List
See also
ListIterator

Implemented in java.util.AbstractList< E >.

◆ listIterator() [2/2]

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

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 list iterator on the elements of this
List
.
Exceptions
IndexOutOfBoundsExceptionif
location < 0 || location > size()
See also
ListIterator

Implemented in java.util.AbstractList< E >.

◆ remove() [1/2]

E java.util.List< E >.remove ( int  location)

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()

Implemented in java.util.Vector< E >, java.util.AbstractList< E >, and java.util.ArrayList< E >.

◆ remove() [2/2]

boolean java.util.List< E >.remove ( Object  object)

Removes the first occurrence of the specified object from this

List

.

Parameters
objectthe object to remove.
Returns
true if this
List
was modified by this operation, false otherwise.
Exceptions
UnsupportedOperationExceptionif removing from this
List
is not supported.

Implements java.util.Collection< E >.

Implemented in java.util.Vector< E >, and java.util.ArrayList< E >.

◆ removeAll()

boolean java.util.List< E >.removeAll ( Collection<?>  collection)

Removes all occurrences in this

List

of each object in the specified collection.

Parameters
collectionthe collection of objects to remove.
Returns
true
if this
List
is modified,
false
otherwise.
Exceptions
UnsupportedOperationExceptionif removing from this
List
is not supported.

Implements java.util.Collection< E >.

Implemented in java.util.Vector< E >.

◆ retainAll()

boolean java.util.List< E >.retainAll ( Collection<?>  collection)

Removes all objects from this

List

that are not contained in the specified collection.

Parameters
collectionthe collection of objects to retain.
Returns
true
if this
List
is modified,
false
otherwise.
Exceptions
UnsupportedOperationExceptionif removing from this
List
is not supported.

Implements java.util.Collection< E >.

Implemented in java.util.Vector< E >.

◆ set()

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

Replaces the element at the specified location in this

List

with the specified object. This operation does not change the size of the

List

.

Parameters
locationthe index at which to put the specified object.
objectthe object to insert.
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()

Implemented in java.util.Vector< E >, java.util.AbstractList< E >, and java.util.ArrayList< E >.

◆ size()

int java.util.List< E >.size ( )

Returns the number of elements in this

List

.

Returns
the number of elements in this
List
.

Implements java.util.Collection< E >.

Implemented in java.util.Vector< E >, and java.util.ArrayList< E >.

◆ subList()

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

Returns a

List

of the specified portion of this

List

from the given start index to the end index minus one. The returned

List

is backed by this

List

so changes to it are reflected by the other.

Parameters
startthe index at which to start the sublist.
endthe index one past the end of the sublist.
Returns
a list of a portion of this
List
.
Exceptions
IndexOutOfBoundsExceptionif
start < 0, start > end
or
end >
size()

Implemented in java.util.Vector< E >, and java.util.AbstractList< E >.

◆ toArray()

Object [] java.util.List< E >.toArray ( )

Returns an array containing all elements contained in this

List

.

Returns
an array of the elements from this
List
.

Implements java.util.Collection< E >.

Implemented in java.util.Vector< E >, and java.util.ArrayList< E >.


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