Package com.jogamp.common.util
Class FloatStack
- java.lang.Object
-
- com.jogamp.common.util.FloatStack
-
- All Implemented Interfaces:
PrimitiveStack
public class FloatStack extends Object implements PrimitiveStack
Simple primitive-type stack.Implemented operations:
- FILO - First In, Last Out
-
-
Constructor Summary
Constructors Constructor Description FloatStack(int initialSize, int growSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description float[]
buffer()
int
capacity()
Returns this stack's current capacity.float[]
getFromTop(float[] dest, int destOffset, int length)
FILO get operationFloatBuffer
getFromTop(FloatBuffer dest, int length)
FILO get operationint
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 operationFloatBuffer
putOnTop(FloatBuffer src, int length)
FILO put operationint
remaining()
Returns the remaining elements left before stack will grow aboutPrimitiveStack.getGrowSize()
.void
setGrowSize(int newGrowSize)
Set new {@link #growSize().String
toString()
-
-
-
Constructor Detail
-
FloatStack
public FloatStack(int initialSize, int growSize)
- Parameters:
initialSize
- initial size, must be > zerogrowSize
- grow size ifposition()
is reached, maybe0
in which case anIndexOutOfBoundsException
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, ifPrimitiveStack.getGrowSize()
> 0.- Specified by:
capacity
in interfacePrimitiveStack
-
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 interfacePrimitiveStack
-
position
public final void position(int newPosition) throws IndexOutOfBoundsException
Description copied from interface:PrimitiveStack
Sets the position of this stack.- Specified by:
position
in interfacePrimitiveStack
- Parameters:
newPosition
- the new position- Throws:
IndexOutOfBoundsException
- ifnewPosition
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 aboutPrimitiveStack.getGrowSize()
.remaining := capacity() - position();
0 denotes a full stack.
- Specified by:
remaining
in interfacePrimitiveStack
- 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'sPrimitiveStack.capacity()
.- Specified by:
getGrowSize
in interfacePrimitiveStack
-
setGrowSize
public final void setGrowSize(int newGrowSize)
Description copied from interface:PrimitiveStack
Set new {@link #growSize().- Specified by:
setGrowSize
in interfacePrimitiveStack
-
buffer
public final float[] buffer()
-
putOnTop
public final float[] putOnTop(float[] src, int srcOffset, int length) throws IndexOutOfBoundsException
FILO put operation- Parameters:
src
- source buffersrcOffset
- offset of srclength
- number of float elements to put fromsrc
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 FloatBuffer putOnTop(FloatBuffer src, int length) throws IndexOutOfBoundsException, BufferUnderflowException
FILO put operation- Parameters:
src
- source buffer, it's position is incremented bylength
length
- number of float elements to put fromsrc
on-top this stack- Returns:
- the src FloatBuffer
- Throws:
IndexOutOfBoundsException
- if stack cannot grow due to zero grow-sizeBufferUnderflowException
- ifsrc
FloatBuffer has less remaining elements thanlength
.
-
getFromTop
public final float[] getFromTop(float[] dest, int destOffset, int length) throws IndexOutOfBoundsException
FILO get operation- Parameters:
dest
- destination bufferdestOffset
- offset of destlength
- number of float elements to get from-top this stack todest
.- Returns:
- the dest float[]
- Throws:
IndexOutOfBoundsException
- if stack ordest
has less elements thanlength
.
-
getFromTop
public final FloatBuffer getFromTop(FloatBuffer dest, int length) throws IndexOutOfBoundsException, BufferOverflowException
FILO get operation- Parameters:
dest
- destination buffer, it's position is incremented bylength
.length
- number of float elements to get from-top this stack todest
.- Returns:
- the dest FloatBuffer
- Throws:
IndexOutOfBoundsException
- if stack has less elements than lengthBufferOverflowException
- ifsrc
FloatBuffer has less remaining elements thanlength
.
-
-