edu.emory.mathcs.backport.java.util
Class LinkedList

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.AbstractSequentialList
              extended byedu.emory.mathcs.backport.java.util.LinkedList
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, Deque, java.util.List, Queue, java.io.Serializable

public class LinkedList
extends java.util.AbstractSequentialList
implements java.util.List, Deque, java.lang.Cloneable, java.io.Serializable

See Also:
Serialized Form

Constructor Summary
LinkedList()
           
LinkedList(java.util.Collection c)
           
 
Method Summary
 void add(int index, java.lang.Object element)
           
 boolean add(java.lang.Object o)
          Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.
 boolean addAll(java.util.Collection c)
           
 boolean addAll(int index, java.util.Collection c)
           
 void addFirst(java.lang.Object e)
          Inserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions.
 void addLast(java.lang.Object e)
          Inserts the specified element at the end of this deque if it is possible to do so immediately without violating capacity restrictions.
 void clear()
           
 java.lang.Object clone()
           
 boolean contains(java.lang.Object o)
          Returns true if this deque contains the specified element.
 java.util.Iterator descendingIterator()
          Returns an iterator over the elements in this deque in reverse sequential order.
 java.lang.Object element()
          Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque).
 java.lang.Object get(int index)
           
 java.lang.Object getFirst()
          Retrieves, but does not remove, the first element of this deque.
 java.lang.Object getLast()
          Retrieves, but does not remove, the last element of this deque.
 int indexOf(java.lang.Object o)
           
 boolean isEmpty()
           
 int lastIndexOf(java.lang.Object o)
           
 java.util.ListIterator listIterator()
           
 java.util.ListIterator listIterator(int index)
           
 boolean offer(java.lang.Object e)
          Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) if it is possible to do so immediately without violating capacity restrictions, returning true upon success and false if no space is currently available.
 boolean offerFirst(java.lang.Object e)
          Inserts the specified element at the front of this deque unless it would violate capacity restrictions.
 boolean offerLast(java.lang.Object e)
          Inserts the specified element at the end of this deque unless it would violate capacity restrictions.
 java.lang.Object peek()
          Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque), or returns null if this deque is empty.
 java.lang.Object peekFirst()
          Retrieves, but does not remove, the first element of this deque, or returns null if this deque is empty.
 java.lang.Object peekLast()
          Retrieves, but does not remove, the last element of this deque, or returns null if this deque is empty.
 java.lang.Object poll()
          Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque), or returns null if this deque is empty.
 java.lang.Object pollFirst()
          Retrieves and removes the first element of this deque, or returns null if this deque is empty.
 java.lang.Object pollLast()
          Retrieves and removes the last element of this deque, or returns null if this deque is empty.
 java.lang.Object pop()
          Pops an element from the stack represented by this deque.
 void push(java.lang.Object e)
          Pushes an element onto the stack represented by this deque (in other words, at the head of this deque) if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.
 java.lang.Object remove()
          Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque).
 java.lang.Object remove(int index)
           
 boolean remove(java.lang.Object o)
          Removes the first occurrence of the specified element from this deque.
 java.lang.Object removeFirst()
          Retrieves and removes the first element of this deque.
 boolean removeFirstOccurrence(java.lang.Object o)
          Removes the first occurrence of the specified element from this deque.
 java.lang.Object removeLast()
          Retrieves and removes the last element of this deque.
 boolean removeLastOccurrence(java.lang.Object o)
          Removes the last occurrence of the specified element from this deque.
 java.lang.Object set(int index, java.lang.Object element)
           
 int size()
          Returns the number of elements in this deque.
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] a)
           
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, removeAll, retainAll, subList
 
Methods inherited from interface edu.emory.mathcs.backport.java.util.Deque
iterator
 

Constructor Detail

LinkedList

public LinkedList()

LinkedList

public LinkedList(java.util.Collection c)
Method Detail

size

public int size()
Description copied from interface: Deque
Returns the number of elements in this deque.

Specified by:
size in interface java.util.List

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.List

contains

public boolean contains(java.lang.Object o)
Description copied from interface: Deque
Returns true if this deque contains the specified element. More formally, returns true if and only if this deque contains at least one element e such that (o==null ? e==null : o.equals(e)).

Specified by:
contains in interface java.util.List

indexOf

public int indexOf(java.lang.Object o)
Specified by:
indexOf in interface java.util.List

lastIndexOf

public int lastIndexOf(java.lang.Object o)
Specified by:
lastIndexOf in interface java.util.List

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.List

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Specified by:
toArray in interface java.util.List

add

public boolean add(java.lang.Object o)
Description copied from interface: Deque
Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available. When using a capacity-restricted deque, it is generally preferable to use offer.

This method is equivalent to Deque.addLast(java.lang.Object).

Specified by:
add in interface java.util.List

remove

public boolean remove(java.lang.Object o)
Description copied from interface: Deque
Removes the first occurrence of the specified element from this deque. If the deque does not contain the element, it is unchanged. More formally, removes the first element e such that (o==null ? e==null : o.equals(e)) (if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call).

This method is equivalent to Deque.removeFirstOccurrence(java.lang.Object).

Specified by:
remove in interface java.util.List

addAll

public boolean addAll(java.util.Collection c)
Specified by:
addAll in interface java.util.List

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Specified by:
addAll in interface java.util.List

clear

public void clear()
Specified by:
clear in interface java.util.List

get

public java.lang.Object get(int index)
Specified by:
get in interface java.util.List

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Specified by:
set in interface java.util.List

add

public void add(int index,
                java.lang.Object element)
Specified by:
add in interface java.util.List

remove

public java.lang.Object remove(int index)
Specified by:
remove in interface java.util.List

listIterator

public java.util.ListIterator listIterator()
Specified by:
listIterator in interface java.util.List

listIterator

public java.util.ListIterator listIterator(int index)
Specified by:
listIterator in interface java.util.List

addFirst

public void addFirst(java.lang.Object e)
Description copied from interface: Deque
Inserts the specified element at the front of this deque if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted deque, it is generally preferable to use method Deque.offerFirst(java.lang.Object).

Specified by:
addFirst in interface Deque
Parameters:
e - the element to add

addLast

public void addLast(java.lang.Object e)
Description copied from interface: Deque
Inserts the specified element at the end of this deque if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted deque, it is generally preferable to use method Deque.offerLast(java.lang.Object).

This method is equivalent to Deque.add(java.lang.Object).

Specified by:
addLast in interface Deque
Parameters:
e - the element to add

offerFirst

public boolean offerFirst(java.lang.Object e)
Description copied from interface: Deque
Inserts the specified element at the front of this deque unless it would violate capacity restrictions. When using a capacity-restricted deque, this method is generally preferable to the Deque.addFirst(java.lang.Object) method, which can fail to insert an element only by throwing an exception.

Specified by:
offerFirst in interface Deque
Parameters:
e - the element to add
Returns:
true if the element was added to this deque, else false

offerLast

public boolean offerLast(java.lang.Object e)
Description copied from interface: Deque
Inserts the specified element at the end of this deque unless it would violate capacity restrictions. When using a capacity-restricted deque, this method is generally preferable to the Deque.addLast(java.lang.Object) method, which can fail to insert an element only by throwing an exception.

Specified by:
offerLast in interface Deque
Parameters:
e - the element to add
Returns:
true if the element was added to this deque, else false

removeFirst

public java.lang.Object removeFirst()
Description copied from interface: Deque
Retrieves and removes the first element of this deque. This method differs from pollFirst only in that it throws an exception if this deque is empty.

Specified by:
removeFirst in interface Deque
Returns:
the head of this deque

removeLast

public java.lang.Object removeLast()
Description copied from interface: Deque
Retrieves and removes the last element of this deque. This method differs from pollLast only in that it throws an exception if this deque is empty.

Specified by:
removeLast in interface Deque
Returns:
the tail of this deque

pollFirst

public java.lang.Object pollFirst()
Description copied from interface: Deque
Retrieves and removes the first element of this deque, or returns null if this deque is empty.

Specified by:
pollFirst in interface Deque
Returns:
the head of this deque, or null if this deque is empty

pollLast

public java.lang.Object pollLast()
Description copied from interface: Deque
Retrieves and removes the last element of this deque, or returns null if this deque is empty.

Specified by:
pollLast in interface Deque
Returns:
the tail of this deque, or null if this deque is empty

getFirst

public java.lang.Object getFirst()
Description copied from interface: Deque
Retrieves, but does not remove, the first element of this deque. This method differs from peekFirst only in that it throws an exception if this deque is empty.

Specified by:
getFirst in interface Deque
Returns:
the head of this deque

getLast

public java.lang.Object getLast()
Description copied from interface: Deque
Retrieves, but does not remove, the last element of this deque. This method differs from peekLast only in that it throws an exception if this deque is empty.

Specified by:
getLast in interface Deque
Returns:
the tail of this deque

peekFirst

public java.lang.Object peekFirst()
Description copied from interface: Deque
Retrieves, but does not remove, the first element of this deque, or returns null if this deque is empty.

Specified by:
peekFirst in interface Deque
Returns:
the head of this deque, or null if this deque is empty

peekLast

public java.lang.Object peekLast()
Description copied from interface: Deque
Retrieves, but does not remove, the last element of this deque, or returns null if this deque is empty.

Specified by:
peekLast in interface Deque
Returns:
the tail of this deque, or null if this deque is empty

removeFirstOccurrence

public boolean removeFirstOccurrence(java.lang.Object o)
Description copied from interface: Deque
Removes the first occurrence of the specified element from this deque. If the deque does not contain the element, it is unchanged. More formally, removes the first element e such that (o==null ? e==null : o.equals(e)) (if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call).

Specified by:
removeFirstOccurrence in interface Deque
Parameters:
o - element to be removed from this deque, if present
Returns:
true if an element was removed as a result of this call

removeLastOccurrence

public boolean removeLastOccurrence(java.lang.Object o)
Description copied from interface: Deque
Removes the last occurrence of the specified element from this deque. If the deque does not contain the element, it is unchanged. More formally, removes the last element e such that (o==null ? e==null : o.equals(e)) (if such an element exists). Returns true if this deque contained the specified element (or equivalently, if this deque changed as a result of the call).

Specified by:
removeLastOccurrence in interface Deque
Parameters:
o - element to be removed from this deque, if present
Returns:
true if an element was removed as a result of this call

offer

public boolean offer(java.lang.Object e)
Description copied from interface: Deque
Inserts the specified element into the queue represented by this deque (in other words, at the tail of this deque) if it is possible to do so immediately without violating capacity restrictions, returning true upon success and false if no space is currently available. When using a capacity-restricted deque, this method is generally preferable to the Deque.add(java.lang.Object) method, which can fail to insert an element only by throwing an exception.

This method is equivalent to Deque.offerLast(java.lang.Object).

Specified by:
offer in interface Deque
Parameters:
e - the element to add
Returns:
true if the element was added to this deque, else false

remove

public java.lang.Object remove()
Description copied from interface: Deque
Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque). This method differs from poll only in that it throws an exception if this deque is empty.

This method is equivalent to Deque.removeFirst().

Specified by:
remove in interface Deque
Returns:
the head of the queue represented by this deque

poll

public java.lang.Object poll()
Description copied from interface: Deque
Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque), or returns null if this deque is empty.

This method is equivalent to Deque.pollFirst().

Specified by:
poll in interface Deque
Returns:
the first element of this deque, or null if this deque is empty

element

public java.lang.Object element()
Description copied from interface: Deque
Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque). This method differs from peek only in that it throws an exception if this deque is empty.

This method is equivalent to Deque.getFirst().

Specified by:
element in interface Deque
Returns:
the head of the queue represented by this deque

peek

public java.lang.Object peek()
Description copied from interface: Deque
Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque), or returns null if this deque is empty.

This method is equivalent to Deque.peekFirst().

Specified by:
peek in interface Deque
Returns:
the head of the queue represented by this deque, or null if this deque is empty

push

public void push(java.lang.Object e)
Description copied from interface: Deque
Pushes an element onto the stack represented by this deque (in other words, at the head of this deque) if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.

This method is equivalent to Deque.addFirst(java.lang.Object).

Specified by:
push in interface Deque
Parameters:
e - the element to push

pop

public java.lang.Object pop()
Description copied from interface: Deque
Pops an element from the stack represented by this deque. In other words, removes and returns the first element of this deque.

This method is equivalent to Deque.removeFirst().

Specified by:
pop in interface Deque
Returns:
the element at the front of this deque (which is the top of the stack represented by this deque)

descendingIterator

public java.util.Iterator descendingIterator()
Description copied from interface: Deque
Returns an iterator over the elements in this deque in reverse sequential order. The elements will be returned in order from last (tail) to first (head).

Specified by:
descendingIterator in interface Deque
Returns:
an iterator over the elements in this deque in reverse sequence

clone

public java.lang.Object clone()