Class Stack<D>

java.lang.Object
  extended by Stack<D>
Type Parameters:
D - The type of the data to store in the stack.

public class Stack<D>
extends java.lang.Object

A list-based implementation of a stack (LIFO-buffer) with only constant time operations.

Author:
Rossmanith

Constructor Summary
Stack()
          Creates an empty stack.
 
Method Summary
 boolean isempty()
          Checks whether this stack is empty.
 D pop()
          Returns and removes the top-most element of this stack.
 void push(D x)
          Pushes the given element x on the top of this stack.
 int size()
          Returns the number of elements in this stack.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Stack

public Stack()
Creates an empty stack.

Method Detail

isempty

public boolean isempty()
Checks whether this stack is empty.

Returns:
true, iff there are no elements stored in this stack.

pop

public D pop()
Returns and removes the top-most element of this stack. May only be called if this stack is non-empty.


push

public void push(D x)
Pushes the given element x on the top of this stack.

Parameters:
x - The element to store in this stack.

size

public int size()
Returns the number of elements in this stack.