fi.joensuu.cs.tra
Class LinkedDeque<E>

java.lang.Object
  extended by java.util.AbstractCollection
      extended by java.util.AbstractList
          extended by java.util.AbstractSequentialList
              extended by java.util.LinkedList
                  extended by fi.joensuu.cs.tra.LinkedDeque
All Implemented Interfaces:
Cloneable, Collection, Iterable, List, Queue, Serializable

public class LinkedDeque<E>
extends LinkedList<E>

LinkedDeque extends java.util.LinkedList to highlight Deque behaviour.

See Also:
LinkedList, Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
LinkedDeque()
          Creates an empty list.
LinkedDeque(Collection<? extends E> c)
          Constructs a deque containing the elements of the specified collection, in the order they are returned by the collection's iterator.
 
Method Summary
 void addFirst(E o)
          Inserts the given element to the front of this deque.
 void addLast(E o)
          Inserts the given element to the rear of this deque.
 void clear()
          Removes all the elements from this deque.
 E getFirst()
          Returns but does not remove the element at the front of this deque.
 E getLast()
          Returns but does not remove the element at the rear of this deque.
 E removeFirst()
          Removes and returns the element at the front of this deque.
 E removeLast()
          Removes and returns the element at the rear of this deque.
 
Methods inherited from class java.util.LinkedList
add, add, addAll, addAll, clone, contains, element, get, indexOf, lastIndexOf, listIterator, offer, peek, poll, remove, remove, remove, set, size, toArray, toArray
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, 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, isEmpty, iterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

LinkedDeque

public LinkedDeque()
Creates an empty list.


LinkedDeque

public LinkedDeque(Collection<? extends E> c)
Constructs a deque containing the elements of the specified collection, in the order they are returned by the collection's iterator.

Parameters:
c - the collection whose elements are to be placed into this deque.
Throws:
NullPointerException - if the specified collection was null.
Method Detail

addFirst

public void addFirst(E o)
Inserts the given element to the front of this deque.

Overrides:
addFirst in class LinkedList
Parameters:
o - the element to be inserted.

addLast

public void addLast(E o)
Inserts the given element to the rear of this deque.

Overrides:
addLast in class LinkedList
Parameters:
o - the element to be inserted.

clear

public void clear()
Removes all the elements from this deque.

Specified by:
clear in interface List
Overrides:
clear in class LinkedList

getFirst

public E getFirst()
Returns but does not remove the element at the front of this deque.

Overrides:
getFirst in class LinkedList
Returns:
the element at the front of this deque or null if this deque is empty.

getLast

public E getLast()
Returns but does not remove the element at the rear of this deque.

Overrides:
getLast in class LinkedList
Returns:
the element at the rear of this deque or null if this deque is empty.

removeFirst

public E removeFirst()
Removes and returns the element at the front of this deque.

Overrides:
removeFirst in class LinkedList
Returns:
the element at the front of this deque or null if this deque is empty.

removeLast

public E removeLast()
Removes and returns the element at the rear of this deque.

Overrides:
removeLast in class LinkedList
Returns:
the element at the rear of this deque or null if this deque is empty.