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

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

public class LinkedStack<E>
extends LinkedList<E>

LinkedStack extends java.util.LinkedList with behaviour expected of a Stack.

See Also:
LinkedList, Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
LinkedStack()
          Creates an empty Stack.
LinkedStack(Collection<? extends E> c)
          Constructs a stack containing the elements of the specified collection, in the order they are returned by the collection's iterator.
 
Method Summary
 void isEmpty()
          Returns true if stack is empty
 E peek()
          Returns but does not remove the element at the top of this stack.
 E pop()
          Removes and returns the element at the top of this stack.
 void push(E o)
          Pushes an element onto the top of this stack.
 
Methods inherited from class java.util.LinkedList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, poll, remove, remove, remove, removeFirst, removeLast, 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, 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, listIterator, removeAll, retainAll, subList
 

Constructor Detail

LinkedStack

public LinkedStack()
Creates an empty Stack.


LinkedStack

public LinkedStack(Collection<? extends E> c)
Constructs a stack 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 stack.
Throws:
NullPointerException - if the specified collection was null.
Method Detail

push

public void push(E o)
Pushes an element onto the top of this stack.

Parameters:
o - the element to be pushed onto this stack.

pop

public E pop()
Removes and returns the element at the top of this stack.

Returns:
the element at the top of this stack or null if this stack is empty.

peek

public E peek()
Returns but does not remove the element at the top of this stack.

Specified by:
peek in interface Queue<E>
Overrides:
peek in class LinkedList<E>
Returns:
the element at the top of this stack or null if this stack is empty.

isEmpty

public void isEmpty()
Returns true if stack is empty