Search this API

y.util
Class BoundedStack

java.lang.Object
  extended by y.util.BoundedStack

public class BoundedStack
extends java.lang.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.
 java.lang.Object pop()
          Returns the element that has been pushed last on this stack and removes it from this stack.
 void push(java.lang.Object o)
          Pushes a new element on this stack.
 int size()
          Returns the number of elements in this stack.
 java.lang.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 java.lang.Object top()
Returns the element that has been pushed last on this stack.

Precondition:
!isEmpty()

pop

public java.lang.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(java.lang.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-2022,
yWorks GmbH.
All rights reserved.