diff options
Diffstat (limited to 'src/java/com')
-rw-r--r-- | src/java/com/jogamp/common/util/FloatStack.java | 10 | ||||
-rw-r--r-- | src/java/com/jogamp/common/util/PrimitiveStack.java | 18 |
2 files changed, 22 insertions, 6 deletions
diff --git a/src/java/com/jogamp/common/util/FloatStack.java b/src/java/com/jogamp/common/util/FloatStack.java index e5790a9..2addd76 100644 --- a/src/java/com/jogamp/common/util/FloatStack.java +++ b/src/java/com/jogamp/common/util/FloatStack.java @@ -63,6 +63,14 @@ public class /*name*/FloatStack/*name*/ implements PrimitiveStack { 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; + } + + @Override public final int remaining() { return buffer.length - position; } @Override @@ -72,7 +80,7 @@ public class /*name*/FloatStack/*name*/ implements PrimitiveStack { public final void setGrowSize(int newGrowSize) { growSize = newGrowSize; } public final String toString() { - return "FloatStack[0..(top "+position+").."+buffer.length+", remaining "+remaining()+"]"; + return "FloatStack[0..(pos "+position+").."+buffer.length+", remaining "+remaining()+"]"; } public final /*value*/float/*value*/[] buffer() { return buffer; } diff --git a/src/java/com/jogamp/common/util/PrimitiveStack.java b/src/java/com/jogamp/common/util/PrimitiveStack.java index 23447e3..89ae72e 100644 --- a/src/java/com/jogamp/common/util/PrimitiveStack.java +++ b/src/java/com/jogamp/common/util/PrimitiveStack.java @@ -41,16 +41,24 @@ public interface PrimitiveStack { int capacity(); /** - * Returns the current position where the next put operation will store the next element. + * Returns the current position of this stack. * <p> - * The position equals to the number of elements already stored. + * Position is in the range: 0 ≤ position < {@link #capacity()}. * </p> - * <p> - * 0 denotes an empty stack. + * <p> + * The position equals to the number of elements stored. * </p> **/ int position(); + /** + * Sets the position of this stack. + * + * @param newPosition the new position + * @throws IndexOutOfBoundsException if <code>newPosition</code> is outside of range: 0 ≤ position < {@link #capacity()}. + */ + void position(int newPosition) throws IndexOutOfBoundsException; + /** * Returns the remaining elements left before stack will grow about {@link #getGrowSize()}. * <pre> @@ -68,5 +76,5 @@ public interface PrimitiveStack { int getGrowSize(); /** Set new {@link #growSize(). */ - void setGrowSize(int newGrowSize); + void setGrowSize(int newGrowSize); } |