| java.lang.Object | ||||
| ↳ | java.util.AbstractCollection<E> | |||
| ↳ | java.util.AbstractList<E> | |||
| ↳ | java.util.AbstractSequentialList<E> | |||
| ↳ | java.util.LinkedList<E> | |||
LinkedList is an implementation of List, backed by a linked list. All optional operations are supported, adding, removing and replacing. The elements can be any objects.
|
[Expand]
Inherited Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.util.AbstractList
| |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new empty instance of LinkedList.
| |||||||||||
Constructs a new instance of
LinkedList that holds
all of the elements contained in the supplied collection
argument. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Inserts the specified object into this LinkedList at the specified
location.
| |||||||||||
Adds the specified object at the end of this LinkedList.
| |||||||||||
Inserts the objects in the specified Collection at the specified location
in this LinkedList.
| |||||||||||
Adds the objects in the specified Collection to this LinkedList.
| |||||||||||
Adds the specified object at the beginning of this LinkedList.
| |||||||||||
Adds the specified object at the end of this LinkedList.
| |||||||||||
Removes all elements from this LinkedList, leaving it empty.
| |||||||||||
Returns a new LinkedList with the same elements and size as this
LinkedList.
| |||||||||||
Searches this LinkedList for the specified object.
| |||||||||||
Gets but not removes the element in the head of the queue.
| |||||||||||
Returns the element at the specified location in this List.
| |||||||||||
Returns the first element in this LinkedList.
| |||||||||||
Returns the last element in this LinkedList.
| |||||||||||
Searches this LinkedList for the specified object and returns the index
of the first occurrence.
| |||||||||||
Searches this LinkedList for the specified object and returns the index
of the last occurrence.
| |||||||||||
Returns a ListIterator on the elements of this LinkedList.
| |||||||||||
Inserts the specified element into the queue provided that the condition
allows such an operation.
| |||||||||||
Gets but not removes the element in the head of the queue, or throws
exception if there is no element in the queue.
| |||||||||||
Gets and removes the element in the head of the queue, or returns null if
there is no element in the queue.
| |||||||||||
Removes the object at the specified location from this LinkedList.
| |||||||||||
Gets and removes the element in the head of the queue.
| |||||||||||
Removes the first occurrence of the specified object from this
Collection.
| |||||||||||
Removes the first object from this LinkedList.
| |||||||||||
Removes the last object from this LinkedList.
| |||||||||||
Replaces the element at the specified location in this LinkedList with
the specified object.
| |||||||||||
Returns the number of elements in this LinkedList.
| |||||||||||
Returns an array containing all elements contained in this LinkedList.
| |||||||||||
Returns a new array containing all elements contained in this LinkedList.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.util.AbstractSequentialList
| |||||||||||
From class java.util.AbstractList
| |||||||||||
From class java.util.AbstractCollection
| |||||||||||
From class java.lang.Object
| |||||||||||
From interface java.lang.Iterable
| |||||||||||
From interface java.util.Collection
| |||||||||||
From interface java.util.List
| |||||||||||
From interface java.util.Queue
| |||||||||||
Constructs a new empty instance of LinkedList.
Constructs a new instance of LinkedList that holds
all of the elements contained in the supplied collection
argument. The order of the elements in this new LinkedList
will be determined by the iteration order of collection.
| collection | the collection of elements to add |
|---|
Inserts the specified object into this LinkedList 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 LinkedList, the object is added at the end.
| location | the index at which to insert |
|---|---|
| object | the object to add |
| IndexOutOfBoundsException | when location < 0 || >= size()
|
|---|
Adds the specified object at the end of this LinkedList.
| object | the object to add |
|---|
Inserts the objects in the specified Collection at the specified location
in this LinkedList. The objects are added in the order they are returned
from the Collection iterator.
| location | the index at which to insert |
|---|---|
| collection | the Collection of objects |
| IndexOutOfBoundsException | when
location < 0 || > size()
|
|---|
Adds the objects in the specified Collection to this LinkedList.
| collection | the Collection of objects |
|---|
Adds the specified object at the beginning of this LinkedList.
| object | the object to add |
|---|
Adds the specified object at the end of this LinkedList.
| object | the object to add |
|---|
Returns a new LinkedList with the same elements and size as this LinkedList.
Searches this LinkedList for the specified object.
| object | the object to search for |
|---|
object is an element of this LinkedList,
false otherwise
Gets but not removes the element in the head of the queue. Throws a NoSuchElementException if there is no element in the queue.
Returns the element at the specified location in this List.
| location | the index of the element to return |
|---|
Returns the first element in this LinkedList.
| NoSuchElementException | when this LinkedList is empty |
|---|
Returns the last element in this LinkedList.
| NoSuchElementException | when this LinkedList is empty |
|---|
Searches this LinkedList for the specified object and returns the index of the first occurrence.
| object | the object to search for |
|---|
Searches this LinkedList for the specified object and returns the index of the last occurrence.
| object | the object to search for |
|---|
Returns a ListIterator on the elements of this LinkedList. The elements are iterated in the same order that they occur in the LinkedList. The iteration starts at the specified location.
| location | the index at which to start the iteration |
|---|
| IndexOutOfBoundsException | when location < 0 || >= size() |
|---|
Inserts the specified element into the queue provided that the condition allows such an operation. The method is generally preferable to the collection.add(E), since the latter might throw an exception if the operation fails.
| o | the specified element to insert into the queue. |
|---|
Gets but not removes the element in the head of the queue, or throws exception if there is no element in the queue.
Gets and removes the element in the head of the queue, or returns null if there is no element in the queue.
Removes the object at the specified location from this LinkedList.
| location | the index of the object to remove |
|---|
| IndexOutOfBoundsException | when location < 0 || >= size()
|
|---|
Gets and removes the element in the head of the queue. Throws a NoSuchElementException if there is no element in the queue.
Removes the first occurrence of the specified object from this Collection. This operation traverses over the collection, looking for the specified object. Once the object is found, the object will be removed from the collection using the iterator's remove method. This collection will throw an UnsupportedOperationException if the iterator returned does not implement remove method, and the specified object is in this collection.
| object | the object to remove |
|---|
Removes the first object from this LinkedList.
| NoSuchElementException | when this LinkedList is empty |
|---|
Removes the last object from this LinkedList.
| NoSuchElementException | when this LinkedList is empty |
|---|
Replaces the element at the specified location in this LinkedList with the specified object.
| location | the index at which to put the specified object |
|---|---|
| object | the object to add |
| IndexOutOfBoundsException | when location < 0 || >= size()
|
|---|
Returns the number of elements in this LinkedList.
Returns an array containing all elements contained in this LinkedList. If the specified array is large enough to hold the elements, the specified array is used, otherwise an array of the same type is created. If the specified array is used and is larger than this LinkedList, the array element following the collection elements is set to null.
| contents | the array |
|---|
| ArrayStoreException | when the type of an element in this LinkedList cannot be stored in the type of the specified array |
|---|
Returns a new array containing all elements contained in this LinkedList.