public class FloatStack extends Object implements PrimitiveStack
Implemented operations:
Constructor and Description |
---|
FloatStack(int initialSize,
int growSize) |
Modifier and Type | Method and Description |
---|---|
float[] |
buffer() |
int |
capacity()
Returns this stack's current capacity.
|
float[] |
getFromTop(float[] dest,
int destOffset,
int length)
FILO get operation
|
FloatBuffer |
getFromTop(FloatBuffer 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.
|
float[] |
putOnTop(float[] src,
int srcOffset,
int length)
FILO put operation
|
FloatBuffer |
putOnTop(FloatBuffer 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 FloatStack(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 PrimitiveStack
public 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 PrimitiveStack
public final void position(int newPosition) throws IndexOutOfBoundsException
PrimitiveStack
position
in interface PrimitiveStack
newPosition
- the new positionIndexOutOfBoundsException
- if newPosition
is outside of range: 0 ≤ position < PrimitiveStack.capacity()
.public final int remaining()
PrimitiveStack
PrimitiveStack.getGrowSize()
.
remaining := capacity() - position();
0 denotes a full stack.
remaining
in interface PrimitiveStack
PrimitiveStack.capacity()
,
PrimitiveStack.position()
public final int getGrowSize()
PrimitiveStack
PrimitiveStack.capacity()
.getGrowSize
in interface PrimitiveStack
public final void setGrowSize(int newGrowSize)
PrimitiveStack
setGrowSize
in interface PrimitiveStack
public final float[] buffer()
public final float[] putOnTop(float[] 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 FloatBuffer putOnTop(FloatBuffer src, int length) throws IndexOutOfBoundsException, BufferUnderflowException
src
- source buffer, it's position is incremented by length
length
- 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 float[] getFromTop(float[] 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 FloatBuffer getFromTop(FloatBuffer 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
.