|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.colorado.collections.CharStack
public class CharStack
A CharStack is a stack of char values.
ensureCapacity, push,
and trimToSize will result in an
OutOfMemoryError when free memory is exhausted.
Integer.MAX_VALUE). Any attempt to create a larger capacity
results in a failure due to an arithmetic overflow.
CharLinkedStack,
ObjectStack,
BooleanStack,
ByteStack,
DoubleStack,
FloatStack,
IntStack,
LongStack,
ShortStack| Constructor Summary | |
|---|---|
CharStack()
Initialize an empty stack with an initial capacity of 10. |
|
CharStack(int initialCapacity)
Initialize an empty stack with a specified initial capacity. |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
Generate a copy of this stack. |
void |
ensureCapacity(int minimumCapacity)
Change the current capacity of this stack. |
int |
getCapacity()
Accessor method to get the current capacity of this stack. |
boolean |
isEmpty()
Determine whether this stack is empty. |
char |
peek()
Get the top item of this stack, without removing the item. |
char |
pop()
Get the top item, removing it from this stack. |
void |
push(char item)
Push a new item onto this stack. |
int |
size()
Accessor method to determine the number of items in this stack. |
void |
trimToSize()
Reduce the current capacity of this stack to its actual size (i.e., the number of items it contains). |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CharStack()
push method works efficiently (without needing more
memory) until this capacity is reached.
- - none
java.lang.OutOfMemoryError - Indicates insufficient memory for:
new char[10].public CharStack(int initialCapacity)
push method works efficiently (without needing more
memory) until this capacity is reached.
initialCapacity - the initial capacity of this stack
initialCapacity is non-negative.
java.lang.IllegalArgumentException - Indicates that initialCapacity is negative.
java.lang.OutOfMemoryError - Indicates insufficient memory for:
new char[initialCapacity].| Method Detail |
|---|
public java.lang.Object clone()
clone in class java.lang.Object- - none
CharStack before it can be used.
java.lang.OutOfMemoryError - Indicates insufficient memory for creating the clone.public void ensureCapacity(int minimumCapacity)
minimumCapacity - the new capacity for this stack
minimumCapacity.
If the capacity was already at or greater than minimumCapacity,
then the capacity is left unchanged.
java.lang.OutOfMemoryError - Indicates insufficient memory for: new char[minimumCapacity].public int getCapacity()
push method works efficiently (without needing
more memory) until this capacity is reached.
- - none
public boolean isEmpty()
- - none
true if this stack is empty;
false otherwise.public char peek()
- - none
java.util.EmptyStackException - Indicates that this stack is empty.public char pop()
- - none
java.util.EmptyStackException - Indicates that this stack is empty.public void push(char item)
item - the item to be pushed onto this stack
java.lang.OutOfMemoryError - Indicates insufficient memory for increasing the stack's capacity.
Integer.MAX_VALUE will cause the stack to fail with an
arithmetic overflow.public int size()
- - none
public void trimToSize()
- - none
java.lang.OutOfMemoryError - Indicates insufficient memory for altering the capacity.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||