Package com.jogamp.common.util
Class FloatStack
java.lang.Object
com.jogamp.common.util.FloatStack
- All Implemented Interfaces:
PrimitiveStack
Simple primitive-type stack.
Implemented operations:
- FILO - First In, Last Out
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal float[]buffer()final intcapacity()Returns this stack's current capacity.final float[]getFromTop(float[] dest, int destOffset, int length) FILO get operationfinal FloatBuffergetFromTop(FloatBuffer dest, int length) FILO get operationfinal intReturns the grow size.final intposition()Returns the current position of this stack.final voidposition(int newPosition) Sets the position of this stack.final float[]putOnTop(float[] src, int srcOffset, int length) FILO put operationfinal FloatBufferputOnTop(FloatBuffer src, int length) FILO put operationfinal intReturns the remaining elements left before stack will grow aboutPrimitiveStack.getGrowSize().final voidsetGrowSize(int newGrowSize) Set new {@link #growSize().final StringtoString()
-
Constructor Details
-
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 Details
-
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
Description 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:
-
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
-
toString
-
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 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 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 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.
-