diff options
Diffstat (limited to 'src/java/com/jogamp/common/util/FloatStack.java')
-rw-r--r-- | src/java/com/jogamp/common/util/FloatStack.java | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/java/com/jogamp/common/util/FloatStack.java b/src/java/com/jogamp/common/util/FloatStack.java index 2addd76..725491c 100644 --- a/src/java/com/jogamp/common/util/FloatStack.java +++ b/src/java/com/jogamp/common/util/FloatStack.java @@ -44,69 +44,69 @@ public class /*name*/FloatStack/*name*/ implements PrimitiveStack { private int position; private /*value*/float/*value*/[] buffer; private int growSize; - + /** * @param initialSize initial size, must be > zero * @param growSize grow size if {@link #position()} is reached, maybe <code>0</code> - * in which case an {@link IndexOutOfBoundsException} is thrown. + * in which case an {@link IndexOutOfBoundsException} is thrown. */ public /*name*/FloatStack/*name*/(int initialSize, int growSize) { this.position = 0; this.growSize = growSize; this.buffer = new /*value*/float/*value*/[initialSize]; } - + @Override public final int capacity() { return buffer.length; } - + @Override public final int position() { return position; } - + @Override public final void position(int newPosition) throws IndexOutOfBoundsException { if( 0 > position || position >= buffer.length ) { throw new IndexOutOfBoundsException("Invalid new position "+newPosition+", "+this.toString()); } - position = newPosition; + position = newPosition; } - + @Override public final int remaining() { return buffer.length - position; } - + @Override public final int getGrowSize() { return growSize; } - + @Override public final void setGrowSize(int newGrowSize) { growSize = newGrowSize; } - + public final String toString() { return "FloatStack[0..(pos "+position+").."+buffer.length+", remaining "+remaining()+"]"; } - + public final /*value*/float/*value*/[] buffer() { return buffer; } - + private final void growIfNecessary(int length) throws IndexOutOfBoundsException { if( position + length > buffer.length ) { if( 0 >= growSize ) { throw new IndexOutOfBoundsException("Out of fixed stack size: "+this); } - /*value*/float/*value*/[] newBuffer = + /*value*/float/*value*/[] newBuffer = new /*value*/float/*value*/[buffer.length + growSize]; System.arraycopy(buffer, 0, newBuffer, 0, position); buffer = newBuffer; - } + } } /** * FILO put operation - * + * * @param src source buffer - * @param srcOffset offset of src - * @param length number of float elements to put from <code>src</code> on-top this stack + * @param srcOffset offset of src + * @param length number of float elements to put from <code>src</code> on-top this stack * @return the src float[] * @throws IndexOutOfBoundsException if stack cannot grow due to zero grow-size or offset+length exceeds src. */ - public final /*value*/float/*value*/[] + public final /*value*/float/*value*/[] putOnTop(/*value*/float/*value*/[] src, int srcOffset, int length) throws IndexOutOfBoundsException { growIfNecessary(length); System.arraycopy(src, srcOffset, buffer, position, length); @@ -116,47 +116,47 @@ public class /*name*/FloatStack/*name*/ implements PrimitiveStack { /** * FILO put operation - * + * * @param src source buffer, it's position is incremented by <code>length</code> - * @param length number of float elements to put from <code>src</code> on-top this stack + * @param length number of float elements to put from <code>src</code> on-top this stack * @return the src FloatBuffer * @throws IndexOutOfBoundsException if stack cannot grow due to zero grow-size * @throws BufferUnderflowException if <code>src</code> FloatBuffer has less remaining elements than <code>length</code>. */ - public final /*value2*/FloatBuffer/*value2*/ + public final /*value2*/FloatBuffer/*value2*/ putOnTop(/*value2*/FloatBuffer/*value2*/ src, int length) throws IndexOutOfBoundsException, BufferUnderflowException { - growIfNecessary(length); + growIfNecessary(length); src.get(buffer, position, length); position += length; return src; } - + /** * FILO get operation - * + * * @param dest destination buffer - * @param destOffset offset of dest - * @param length number of float elements to get from-top this stack to <code>dest</code>. + * @param destOffset offset of dest + * @param length number of float elements to get from-top this stack to <code>dest</code>. * @return the dest float[] * @throws IndexOutOfBoundsException if stack or <code>dest</code> has less elements than <code>length</code>. */ - public final /*value*/float/*value*/[] + public final /*value*/float/*value*/[] getFromTop(/*value*/float/*value*/[] dest, int destOffset, int length) throws IndexOutOfBoundsException { System.arraycopy(buffer, position-length, dest, destOffset, length); position -= length; return dest; } - + /** * FILO get operation - * + * * @param dest destination buffer, it's position is incremented by <code>length</code>. * @param length number of float elements to get from-top this stack to <code>dest</code>. * @return the dest FloatBuffer * @throws IndexOutOfBoundsException if stack has less elements than length * @throws BufferOverflowException if <code>src</code> FloatBuffer has less remaining elements than <code>length</code>. */ - public final /*value2*/FloatBuffer/*value2*/ + public final /*value2*/FloatBuffer/*value2*/ getFromTop(/*value2*/FloatBuffer/*value2*/ dest, int length) throws IndexOutOfBoundsException, BufferOverflowException { dest.put(buffer, position-length, length); position -= length; |