y.util
Class BoundedStack

java.lang.Object
  |
  +--y.util.BoundedStack

public class BoundedStack
extends Object

This class represents an efficient stack of bounded size.


Constructor Summary
BoundedStack(int capacity)
          Creates a new instance of BoundedStack.
 
Method Summary
 int capacity()
          Returns the maximal number of elements that this stack can hold.
 void clear()
          Removes all elements from this stack;
 boolean isEmpty()
          Returns true if this stack is empty.
 Object pop()
          Returns the element that has been pushed last on this stack and removes it from this stack.
 void push(Object o)
          Pushes a new element on this stack.
 int size()
          Returns the number of elements in this stack.
 Object top()
          Returns the element that has been pushed last on this stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoundedStack

public BoundedStack(int capacity)
Creates a new instance of BoundedStack.

Parameters:
capacity - the maximum capacity of this queue.
Method Detail

top

public Object top()
Returns the element that has been pushed last on this stack.

Precondition:!isEmpty()


pop

public Object pop()
Returns the element that has been pushed last on this stack and removes it from this stack.

Precondition:!isEmpty()


push

public void push(Object o)
Pushes a new element on this stack.


clear

public void clear()
Removes all elements from this stack;


size

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


capacity

public int capacity()
Returns the maximal number of elements that this stack can hold.


isEmpty

public boolean isEmpty()
Returns true if this stack is empty.


© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003