| 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 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 
        LinkedList()
        
         Constructs a new empty instance of  
  
  LinkedList. | |||||||||||
| 
        LinkedList(Collection<? extends E> collection)
        
         Constructs a new instance of  
  
  LinkedList that holds all of the
 elements contained in the specified collection. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| void | 
        add(int location, Object object)
        
         Inserts the specified object into this  
  
  LinkedList at the specified
 location. | ||||||||||
| boolean | 
        add(Object object)
        
         Adds the specified object at the end of this  
  
  LinkedList. | ||||||||||
| boolean | 
        addAll(Collection<? extends E> collection)
        
         Adds the objects in the specified Collection to this  
  
  LinkedList. | ||||||||||
| boolean | 
        addAll(int location, Collection<? extends E> collection)
        
         Inserts the objects in the specified collection at the specified location in
 this  
  
  LinkedList. | ||||||||||
| void | 
        addFirst(Object object)
        
         Adds the specified object at the beginning of this  
  
  LinkedList. | ||||||||||
| void | 
        addLast(Object object)
        
         Adds the specified object at the end of this  
  
  LinkedList. | ||||||||||
| void | 
        clear()
        
         Removes all elements from this  
  
  LinkedList, leaving it empty. | ||||||||||
| boolean | 
        contains(Object object)
        
         Searches this  
  
  LinkedList for the specified object. | ||||||||||
| Iterator<E> | 
        descendingIterator()
        
         Returns the iterator in reverse order, from tail to head. 
  
   | ||||||||||
| E | 
        element()
        
         Gets but does not remove the element at the head of the queue. 
  
   | ||||||||||
| E | 
        get(int location)
        
         Returns the element at the specified location in this list. 
  
   | ||||||||||
| E | 
        getFirst()
        
         Returns the first element in this  
  
  LinkedList. | ||||||||||
| E | 
        getLast()
        
         Returns the last element in this  
  
  LinkedList. | ||||||||||
| int | 
        indexOf(Object object)
        
         Searches this list for the specified object and returns the index of the
 first occurrence. 
  
   | ||||||||||
| int | 
        lastIndexOf(Object object)
        
         Searches this  
  
  LinkedList for the specified object and returns the
 index of the last occurrence. | ||||||||||
| ListIterator<E> | 
        listIterator(int location)
        
         Returns a ListIterator on the elements of this  
  
  LinkedList. | ||||||||||
| boolean | offer(Object o) | ||||||||||
| boolean | offerFirst(Object e) | ||||||||||
| boolean | offerLast(Object e) | ||||||||||
| E | 
        peek()
        
         Gets but does not remove the element at the head of the queue. 
  
   | ||||||||||
| E | 
        peekFirst()
        
         Gets but not removes the head element of this deque. 
  
   | ||||||||||
| E | 
        peekLast()
        
         Gets but not removes the tail element of this deque. 
  
   | ||||||||||
| E | 
        poll()
        
         Gets and removes the element at the head of the queue, or returns  
  
  null if there is no element in the queue. | ||||||||||
| E | 
        pollFirst()
        
         Gets and removes the head element of this deque. 
  
   | ||||||||||
| E | 
        pollLast()
        
         Gets and removes the tail element of this deque. 
  
   | ||||||||||
| E | 
        pop()
        
         Pops the head element of the deque, just same as removeFirst(). 
  
   | ||||||||||
| void | push(Object e) | ||||||||||
| E | 
        remove(int location)
        
         Removes the object at the specified location from this  
  
  LinkedList. | ||||||||||
| E | 
        remove()
        
         Gets and removes the element at the head of the queue. 
  
   | ||||||||||
| boolean | 
        remove(Object object)
        
         Removes one instance of the specified object from this  
  
  Collection if
 one is contained (optional). | ||||||||||
| E | 
        removeFirst()
        
         Removes the first object from this  
  
  LinkedList. | ||||||||||
| boolean | 
        removeFirstOccurrence(Object o)
        
         Removes the first equivalent element of the specified object. 
  
   | ||||||||||
| E | 
        removeLast()
        
         Removes the last object from this  
  
  LinkedList. | ||||||||||
| boolean | 
        removeLastOccurrence(Object o)
        
         Removes the last equivalent element of the specified object. 
  
   | ||||||||||
| E | 
        set(int location, Object object)
        
         Replaces the element at the specified location in this  
  
  LinkedList
 with the specified object. | ||||||||||
| int | 
        size()
        
         Returns the number of elements in this  
  
  LinkedList. | ||||||||||
| Object[] | 
        toArray()
        
         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.Deque
 | |||||||||||
   
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 specified collection. 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 | if location < 0 || >= size()
 | 
        
|---|
Adds the specified object at the end of this LinkedList.
| object | the object to add. | 
|---|
Adds the objects in the specified Collection to this LinkedList.
| collection | the collection of objects. | 
|---|
true if this LinkedList is modified, false
         otherwise.
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's iterator.
| location | the index at which to insert. | 
|---|---|
| collection | the collection of objects | 
true if this LinkedList is modified, false
         otherwise.| ClassCastException | if the class of an object is inappropriate for this list. | 
|---|---|
| IllegalArgumentException | if an object cannot be added to this list. | 
| IndexOutOfBoundsException | if location < 0 || > size()
 | 
        
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. | 
|---|
Searches this LinkedList for the specified object.
| object | the object to search for. | 
|---|
true if object is an element of this
         LinkedList, false otherwise
Returns the iterator in reverse order, from tail to head.
Gets but does not remove the element at 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 | if this LinkedList is empty.
 | 
        
|---|
Returns the last element in this LinkedList.
| NoSuchElementException | if this LinkedList is empty
 | 
        
|---|
Searches this list 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 | 
|---|
LinkedList| IndexOutOfBoundsException | if location < 0 || >= size() | 
        
|---|
Gets but does not remove the element at the head of the queue.
null if there is no
         element in the queue.
Gets but not removes the head element of this deque. This method returns null if the deque is empty.
Gets but not removes the tail element of this deque. This method returns null if the deque is empty.
Gets and removes the element at the head of the queue, or returns null if there is no element in the queue.
null if there is no
         element in the queue.
Gets and removes the head element of this deque. This method returns null if the deque is empty.
Gets and removes the tail element of this deque. This method returns null if the deque is empty.
Pops the head element of the deque, just same as removeFirst().
Removes the object at the specified location from this LinkedList.
| location | the index of the object to remove | 
|---|
| IndexOutOfBoundsException | if location < 0 || >= size()
 | 
        
|---|
Gets and removes the element at the head of the queue. Throws a NoSuchElementException if there is no element in the queue.
Removes one instance of the specified object from this Collection if
 one is contained (optional). This implementation iterates over this
 Collection and tests for each element e returned by the
 iterator, whether e is equal to the given object. If
 object != null then this test is performed using
 object.equals(e), otherwise using object == null. If an
 element equal to the given object is found, then the remove method is
 called on the iterator and true is returned, false otherwise.
 If the iterator does not support removing elements, an
 UnsupportedOperationException is thrown.
| object | the object to remove. | 
|---|
true if this Collection is modified, false
         otherwise.Removes the first object from this LinkedList.
| NoSuchElementException | if this LinkedList is empty.
 | 
        
|---|
Removes the first equivalent element of the specified object. If the deque does not contain the element, it is unchanged and returns false.
| o | the element to be removed | 
|---|
Removes the last object from this LinkedList.
| NoSuchElementException | if this LinkedList is empty.
 | 
        
|---|
Removes the last equivalent element of the specified object. If the deque does not contain the element, it is unchanged and returns false.
| o | the element to be removed | 
|---|
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. | 
| ClassCastException | if the class of an object is inappropriate for this list. | 
|---|---|
| IllegalArgumentException | if an object cannot be added to this list. | 
| IndexOutOfBoundsException | if location < 0 || >= size()
 | 
        
Returns the number of elements in this LinkedList.
LinkedList.
Returns a new array containing all elements contained in this
 LinkedList.
LinkedList.