com.jogamp.common.util
Class IntegerStack

java.lang.Object
  extended by com.jogamp.common.util.IntegerStack
All Implemented Interfaces:
PrimitiveStack

public class IntegerStack
extends Object
implements PrimitiveStack

Simple primitive-type stack.

Implemented operations:


Constructor Summary
IntegerStack(int initialSize, int growSize)
           
 
Method Summary
 int[] buffer()
           
 int capacity()
          Returns this stack's current capacity.
 int[] getFromTop(int[] dest, int destOffset, int length)
          FILO get operation
 IntBuffer getFromTop(IntBuffer dest, int length)
          FILO get operation
 int getGrowSize()
          Returns the grow size.
 int position()
          Returns the current position of this stack.
 void position(int newPosition)
          Sets the position of this stack.
 int[] putOnTop(int[] src, int srcOffset, int length)
          FILO put operation
 IntBuffer putOnTop(IntBuffer src, int length)
          FILO put operation
 int remaining()
          Returns the remaining elements left before stack will grow about PrimitiveStack.getGrowSize().
 void setGrowSize(int newGrowSize)
          Set new {@link #growSize().
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntegerStack

public IntegerStack(int initialSize,
                    int growSize)
Parameters:
initialSize - initial size, must be > zero
growSize - grow size if position() is reached, maybe 0 in which case an IndexOutOfBoundsException is thrown.
Method Detail

capacity

public final int capacity()
Description copied from interface: PrimitiveStack
Returns this stack's current capacity.

The capacity may grow with a put operation w/ insufficient PrimitiveStack.remaining() elements left, if PrimitiveStack.getGrowSize() > 0.

Specified by:
capacity in interface PrimitiveStack

position

public final int position()
Description copied from interface: PrimitiveStack
Returns the current position of this stack.

Position is in the range: 0 ≤ position < PrimitiveStack.capacity().

The position equals to the number of elements stored.

Specified by:
position in interface PrimitiveStack

position

public final void position(int newPosition)
                    throws IndexOutOfBoundsException
Description copied from interface: PrimitiveStack
Sets the position of this stack.

Specified by:
position in interface PrimitiveStack
Parameters:
newPosition - the new position
Throws:
IndexOutOfBoundsException - if newPosition is outside of range: 0 ≤ position < PrimitiveStack.capacity().

remaining

public final int remaining()
Description copied from interface: PrimitiveStack
Returns the remaining elements left before stack will grow about PrimitiveStack.getGrowSize().
   remaining := capacity() - position();
 

0 denotes a full stack.

Specified by:
remaining in interface PrimitiveStack
See Also:
PrimitiveStack.capacity(), PrimitiveStack.position()

getGrowSize

public final int getGrowSize()
Description copied from interface: PrimitiveStack
Returns the grow size. A stack grows by this size in case a put operation exceeds it's PrimitiveStack.capacity().

Specified by:
getGrowSize in interface PrimitiveStack

setGrowSize

public final void setGrowSize(int newGrowSize)
Description copied from interface: PrimitiveStack
Set new {@link #growSize().

Specified by:
setGrowSize in interface PrimitiveStack

toString

public final String toString()
Overrides:
toString in class Object

buffer

public final int[] buffer()

putOnTop

public final int[] putOnTop(int[] src,
                            int srcOffset,
                            int length)
                     throws IndexOutOfBoundsException
FILO put operation

Parameters:
src - source buffer
srcOffset - offset of src
length - number of float elements to put from src on-top this stack
Returns:
the src float[]
Throws:
IndexOutOfBoundsException - if stack cannot grow due to zero grow-size or offset+length exceeds src.

putOnTop

public final IntBuffer putOnTop(IntBuffer src,
                                int length)
                         throws IndexOutOfBoundsException,
                                BufferUnderflowException
FILO put operation

Parameters:
src - source buffer, it's position is incremented by length
length - number of float elements to put from src on-top this stack
Returns:
the src FloatBuffer
Throws:
IndexOutOfBoundsException - if stack cannot grow due to zero grow-size
BufferUnderflowException - if src FloatBuffer has less remaining elements than length.

getFromTop

public final int[] getFromTop(int[] dest,
                              int destOffset,
                              int length)
                       throws IndexOutOfBoundsException
FILO get operation

Parameters:
dest - destination buffer
destOffset - offset of dest
length - number of float elements to get from-top this stack to dest.
Returns:
the dest float[]
Throws:
IndexOutOfBoundsException - if stack or dest has less elements than length.

getFromTop

public final IntBuffer getFromTop(IntBuffer dest,
                                  int length)
                           throws IndexOutOfBoundsException,
                                  BufferOverflowException
FILO get operation

Parameters:
dest - destination buffer, it's position is incremented by length.
length - number of float elements to get from-top this stack to dest.
Returns:
the dest FloatBuffer
Throws:
IndexOutOfBoundsException - if stack has less elements than length
BufferOverflowException - if src FloatBuffer has less remaining elements than length.