org.jaitools.jiffle.runtime
Class IntegerStack

java.lang.Object
  extended by org.jaitools.jiffle.runtime.IntegerStack

public class IntegerStack
extends java.lang.Object

A simple, array-based stack for Integer values used by AbstractJiffleRuntime. This class is here to avoid using generic collections (which the Janino compiler does not support) or littering the runtime source code with casts.

Since:
0.1
Version:
$Id: IntegerStack.java 1653 2011-06-16 10:23:02Z michael.bedward $
Author:
Michael Bedward

Field Summary
static int CHUNK_SIZE
          Initial size of stack and grow increment
static int CLEAR_SIZE
          Stack size beyond which the data array will be shrunk when clear() is called.
 
Constructor Summary
IntegerStack()
           
 
Method Summary
 void clear()
          Clear the stack.
 java.lang.Integer peek()
          Peek at the top value without removing it.
 java.lang.Integer pop()
          Pop the top value off the stack.
 java.lang.Integer push(java.lang.Integer x)
          Push a value onto the stack.
 int size()
          Gets the number of items on the stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHUNK_SIZE

public static final int CHUNK_SIZE
Initial size of stack and grow increment

See Also:
Constant Field Values

CLEAR_SIZE

public static final int CLEAR_SIZE
Stack size beyond which the data array will be shrunk when clear() is called.

See Also:
Constant Field Values
Constructor Detail

IntegerStack

public IntegerStack()
Method Detail

push

public java.lang.Integer push(java.lang.Integer x)
Push a value onto the stack.

Parameters:
x - the value
Returns:
the value

pop

public java.lang.Integer pop()
Pop the top value off the stack.

Returns:
the value
Throws:
java.lang.RuntimeException - if the stack is empty

peek

public java.lang.Integer peek()
Peek at the top value without removing it.

Returns:
the value
Throws:
java.lang.RuntimeException - if the stack is empty

clear

public void clear()
Clear the stack. If the stack size if above CLEAR_SIZE the data array is shrunk to its initial size.


size

public int size()
Gets the number of items on the stack.

Returns:
number of items.


Copyright © 2011. All Rights Reserved.