Package gnu.trove
Class TIntStack
java.lang.Object
gnu.trove.TIntStack
A stack of int primitives, backed by a TIntArrayList.
- Version:
- $Id: PStack.template,v 1.2 2007/02/28 23:03:57 robeden Exp $
- Author:
- Eric D. Friedman, Rob Eden
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TIntArrayListthe list used to hold the stack values.static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the stack, reseting its capacity to the default.intpeek()Returns the value at the top of the stack.intpop()Removes and returns the value at the top of the stack.voidpush(int val) Pushes the value onto the top of the stack.voidreset()Clears the stack without releasing its internal capacity allocation.intsize()Returns the current depth of the stack.int[]Copies the contents of the stack into a native array.voidtoNativeArray(int[] dest) Copies a slice of the list into a native array.
-
Field Details
-
_list
the list used to hold the stack values. -
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITY- See Also:
-
-
Constructor Details
-
TIntStack
public TIntStack()Creates a newTIntStackinstance with the default capacity. -
TIntStack
public TIntStack(int capacity) Creates a newTIntStackinstance with the specified capacity.- Parameters:
capacity- the initial depth of the stack
-
-
Method Details
-
push
public void push(int val) Pushes the value onto the top of the stack.- Parameters:
val- anintvalue
-
pop
public int pop()Removes and returns the value at the top of the stack.- Returns:
- an
intvalue
-
peek
public int peek()Returns the value at the top of the stack.- Returns:
- an
intvalue
-
size
public int size()Returns the current depth of the stack. -
clear
public void clear()Clears the stack, reseting its capacity to the default. -
reset
public void reset()Clears the stack without releasing its internal capacity allocation. -
toNativeArray
public int[] toNativeArray()Copies the contents of the stack into a native array. Note that this will NOT pop them out of the stack.- Returns:
- an
int[]value
-
toNativeArray
public void toNativeArray(int[] dest) Copies a slice of the list into a native array. Note that this will NOT pop them out of the stack.- Parameters:
dest- the array to copy into.
-