Package org.web3d.util
Class BooleanStack
java.lang.Object
org.web3d.util.BooleanStack
A stack that is based on boolean values.
This stack is designed to be used in a high-speed, single threaded environment. It is directly backed by an array for fast access. Similar to the SimpleStack, but some methods not provided as they don't make sense.
- Version:
- $Revision: 1.3 $
- Author:
- Justin Couch
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new, empty hashtable with a default capacity and load factor, which is20
respectively.BooleanStack
(int initialCapacity) Constructs a new, empty hashtable with the specified initial capacity and default load factor, which is0.75
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears this stack so that it contains no values.boolean
isEmpty()
Tests if this stack maps no values.boolean
peek()
Peek at the value on the top of the stack without removing it.boolean
pop()
Pop the value from the top of the stack.void
push
(boolean val) Push a new value onto the top of the stack.int
size()
Returns the number of keys in this hashtable.toString()
-
Constructor Details
-
BooleanStack
public BooleanStack()Constructs a new, empty hashtable with a default capacity and load factor, which is20
respectively. -
BooleanStack
public BooleanStack(int initialCapacity) Constructs a new, empty hashtable with the specified initial capacity and default load factor, which is0.75
.- Parameters:
initialCapacity
- the initial capacity of the hashtable.- Throws:
IllegalArgumentException
- if the initial capacity is less than zero.
-
-
Method Details
-
size
public int size()Returns the number of keys in this hashtable.- Returns:
- the number of keys in this hashtable.
-
isEmpty
public boolean isEmpty()Tests if this stack maps no values.- Returns:
true
if this stack has no values
-
push
public void push(boolean val) Push a new value onto the top of the stack. The value may be any legal reference to an object including null.- Parameters:
val
- The new value for the stack.
-
peek
Peek at the value on the top of the stack without removing it. If the value pushed was null, then null is returned here.- Returns:
- A reference to the object on the top of the stack
- Throws:
EmptyStackException
- The stack is currently empty
-
pop
public boolean pop()Pop the value from the top of the stack. If the last value in the stack was null then this will return null.- Returns:
- The top object on the stack
-
clear
public void clear()Clears this stack so that it contains no values. -
toString
-