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()intcapacity()Returns this stack's current capacity.float[]getFromTop(float[] dest, int destOffset, int length)FILO get operationFloatBuffergetFromTop(FloatBuffer dest, int length)FILO get operationintgetGrowSize()Returns the grow size.intposition()Returns the current position of this stack.voidposition(int newPosition)Sets the position of this stack.float[]putOnTop(float[] src, int srcOffset, int length)FILO put operationFloatBufferputOnTop(FloatBuffer src, int length)FILO put operationintremaining()Returns the remaining elements left before stack will grow aboutPrimitiveStack.getGrowSize().voidsetGrowSize(int newGrowSize)Set new {@link #growSize().StringtoString()
-
-
-
Constructor Detail
-
FloatStack
public FloatStack(int initialSize, int growSize)- Parameters:
initialSize- initial size, must be > zerogrowSize- grow size ifposition()is reached, maybe0in which case anIndexOutOfBoundsExceptionis thrown.
-
-
Method Detail
-
capacity
public final int capacity()
Description copied from interface:PrimitiveStackReturns this stack's current capacity.The capacity may grow with a put operation w/ insufficient
PrimitiveStack.remaining()elements left, ifPrimitiveStack.getGrowSize()> 0.- Specified by:
capacityin interfacePrimitiveStack
-
position
public final int position()
Description copied from interface:PrimitiveStackReturns 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:
positionin interfacePrimitiveStack
-
position
public final void position(int newPosition) throws IndexOutOfBoundsExceptionDescription copied from interface:PrimitiveStackSets the position of this stack.- Specified by:
positionin interfacePrimitiveStack- Parameters:
newPosition- the new position- Throws:
IndexOutOfBoundsException- ifnewPositionis outside of range: 0 ≤ position <PrimitiveStack.capacity().
-
remaining
public final int remaining()
Description copied from interface:PrimitiveStackReturns the remaining elements left before stack will grow aboutPrimitiveStack.getGrowSize().remaining := capacity() - position();
0 denotes a full stack.
- Specified by:
remainingin interfacePrimitiveStack- See Also:
PrimitiveStack.capacity(),PrimitiveStack.position()
-
getGrowSize
public final int getGrowSize()
Description copied from interface:PrimitiveStackReturns the grow size. A stack grows by this size in case a put operation exceeds it'sPrimitiveStack.capacity().- Specified by:
getGrowSizein interfacePrimitiveStack
-
setGrowSize
public final void setGrowSize(int newGrowSize)
Description copied from interface:PrimitiveStackSet new {@link #growSize().- Specified by:
setGrowSizein interfacePrimitiveStack
-
buffer
public final float[] buffer()
-
putOnTop
public final float[] putOnTop(float[] src, int srcOffset, int length) throws IndexOutOfBoundsExceptionFILO put operation- Parameters:
src- source buffersrcOffset- offset of srclength- number of float elements to put fromsrcon-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 bylengthlength- number of float elements to put fromsrcon-top this stack- Returns:
- the src FloatBuffer
- Throws:
IndexOutOfBoundsException- if stack cannot grow due to zero grow-sizeBufferUnderflowException- ifsrcFloatBuffer has less remaining elements thanlength.
-
getFromTop
public final float[] getFromTop(float[] dest, int destOffset, int length) throws IndexOutOfBoundsExceptionFILO 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 ordesthas 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- ifsrcFloatBuffer has less remaining elements thanlength.
-
-