TPTP 4.2.0 Platform Project
Public API Specification

org.eclipse.hyades.collection.correlation
Class Stack

java.lang.Object
  extended byorg.eclipse.hyades.collection.correlation.Stack
Direct Known Subclasses:
CorrelatorStack, ServiceRegistry

public class Stack
extends java.lang.Object

This class offers a simple and efficient implementation of a thread-safe, growable stack.


Field Summary
protected  int increment
          The size by which the stack grows if more space is required.
 java.lang.Object privateStorage
          Any private storage that may be necessary for this class.
protected  java.lang.Object[] stack
          The stack of objects.
protected  int top
          The top-most item on the stack.
 
Constructor Summary
Stack(int size, int increment)
          Creates an empty stack of size with an increment for holding Objects.
 
Method Summary
 java.lang.Object peek()
          Peeks at the top-most item on the stack, or returns null if the stack is empty.
 java.lang.Object peek(int offset)
          Peeks at the offsetth item from the top of the stack, with the top-most item being 0.
 java.lang.Object pop()
          Pops the top-most item off the stack, or null if the stack if empty.
 void push(java.lang.Object item)
          Pushes an item onto the stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stack

protected java.lang.Object[] stack
The stack of objects.


top

protected int top
The top-most item on the stack. A value of -1 indicates that the stack is currently empty.


increment

protected int increment
The size by which the stack grows if more space is required.


privateStorage

public java.lang.Object privateStorage
Any private storage that may be necessary for this class. This is particularly useful when the generality of a super-class and the specialization of a sub-class are desired at the same time, making sub-classing unfeasible. This field is not managed by the class.

Constructor Detail

Stack

public Stack(int size,
             int increment)
Creates an empty stack of size with an increment for holding Objects.

Parameters:
size - the initial size of the stack
increment - the size by which the stack grows if its current capacity is insufficient
Method Detail

peek

public java.lang.Object peek()
Peeks at the top-most item on the stack, or returns null if the stack is empty.

Returns:
the top-most item on the stack, or null if the stack is empty.

peek

public java.lang.Object peek(int offset)
Peeks at the offsetth item from the top of the stack, with the top-most item being 0.

Parameters:
offset - any non-negative value indicating the desired item on the stack
Returns:
the offsetth item from the top of the stack, or null if the offset is out of range.

push

public void push(java.lang.Object item)
Pushes an item onto the stack. If there is no room left on the stack, the size of the stack is incremented automatically by increment, after which the item is pushed onto the new stack.

Parameters:
item - the object to be pushed onto the stack

pop

public java.lang.Object pop()
Pops the top-most item off the stack, or null if the stack if empty.

Returns:
the top-most item on the stack, or null if the stack is empty.

TPTP 4.2.0 Platform Project
Public API Specification