public class IntegerStack extends Object implements PrimitiveStack
Implemented operations:
| Constructor and Description |
|---|
IntegerStack(int initialSize,
int growSize) |
| Modifier and Type | Method and Description |
|---|---|
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() |
public IntegerStack(int initialSize,
int growSize)
initialSize - initial size, must be > zerogrowSize - grow size if position() is reached, maybe 0
in which case an IndexOutOfBoundsException is thrown.public final int capacity()
PrimitiveStack
The capacity may grow with a put operation w/ insufficient PrimitiveStack.remaining() elements left, if PrimitiveStack.getGrowSize() > 0.
capacity in interface PrimitiveStackpublic final int position()
PrimitiveStack
Position is in the range: 0 ≤ position < PrimitiveStack.capacity().
The position equals to the number of elements stored.
position in interface PrimitiveStackpublic final void position(int newPosition)
throws IndexOutOfBoundsException
PrimitiveStackposition in interface PrimitiveStacknewPosition - the new positionIndexOutOfBoundsException - if newPosition is outside of range: 0 ≤ position < PrimitiveStack.capacity().public final int remaining()
PrimitiveStackPrimitiveStack.getGrowSize().
remaining := capacity() - position();
0 denotes a full stack.
remaining in interface PrimitiveStackPrimitiveStack.capacity(),
PrimitiveStack.position()public final int getGrowSize()
PrimitiveStackPrimitiveStack.capacity().getGrowSize in interface PrimitiveStackpublic final void setGrowSize(int newGrowSize)
PrimitiveStacksetGrowSize in interface PrimitiveStackpublic final int[] buffer()
public final int[] putOnTop(int[] src,
int srcOffset,
int length)
throws IndexOutOfBoundsException
src - source buffersrcOffset - offset of srclength - number of float elements to put from src on-top this stackIndexOutOfBoundsException - if stack cannot grow due to zero grow-size or offset+length exceeds src.public final IntBuffer putOnTop(IntBuffer src, int length) throws IndexOutOfBoundsException, BufferUnderflowException
src - source buffer, it's position is incremented by lengthlength - number of float elements to put from src on-top this stackIndexOutOfBoundsException - if stack cannot grow due to zero grow-sizeBufferUnderflowException - if src FloatBuffer has less remaining elements than length.public final int[] getFromTop(int[] dest,
int destOffset,
int length)
throws IndexOutOfBoundsException
dest - destination bufferdestOffset - offset of destlength - number of float elements to get from-top this stack to dest.IndexOutOfBoundsException - if stack or dest has less elements than length.public final IntBuffer getFromTop(IntBuffer dest, int length) throws IndexOutOfBoundsException, BufferOverflowException
dest - destination buffer, it's position is incremented by length.length - number of float elements to get from-top this stack to dest.IndexOutOfBoundsException - if stack has less elements than lengthBufferOverflowException - if src FloatBuffer has less remaining elements than length.