fi.joensuu.cs.tra
Class LinkedStack<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.LinkedStack
All Implemented Interfaces:
Cloneable, Collection, Iterable, List, Queue, Serializable

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 clear()
          Removes all the elements from this stack.
 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, 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, 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

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
Overrides:
peek in class LinkedList
Returns:
the element at the top of this stack or null if this stack is empty.

clear

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

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