All Packages Class Hierarchy This Package Previous Next Index
Class sdsu.util.CharStack
java.lang.Object
|
+----sdsu.util.CharStack
- public final class CharStack
- extends Object
This class implements a characater stack. Yes the JKD does contain
a general stack. However that stack operates on objects. This stack
just handles char elements. Use in IO operations where converting
chars to objects will be too expensive.
- Version:
- 1.0 21 August 1997
- Author:
- Roger Whitney (whitney@cs.sdsu.edu)
-
DEFAULT_QUEUE_SIZE
-
-
CharStack()
- Create a stack of the default size.
-
CharStack(int)
- Create a stack with the given initial size.
-
capacity()
- Returns the total number of locations,, used or not, for chars in the stack
-
clear()
- Removes all elements from the stack.
-
isEmpty()
- Returns true is stack is empty.
-
peek()
- Returns the top char on the stack.
-
pop()
- Remove and return the top char on the stack.
-
push(char)
- Adds a char to the top of the stack.
-
push(char[])
- Adds an array of characters to the stack.
-
push(String)
- Adds an array of characters to the stack.
-
toString()
-
DEFAULT_QUEUE_SIZE
public static final int DEFAULT_QUEUE_SIZE
CharStack
public CharStack()
- Create a stack of the default size.
CharStack
public CharStack(int initialSize)
- Create a stack with the given initial size.
toString
public String toString()
- Overrides:
- toString in class Object
isEmpty
public boolean isEmpty()
- Returns true is stack is empty.
pop
public char pop()
- Remove and return the top char on the stack.
Assumes stack is not empty.
peek
public char peek()
- Returns the top char on the stack. Does not remove any elements.
Assumes stack is not empty.
capacity
public int capacity()
- Returns the total number of locations,, used or not, for chars in the stack
push
public void push(char addMe)
- Adds a char to the top of the stack.
push
public void push(char addMe[])
- Adds an array of characters to the stack.
First element of the array is pushed first.
push
public void push(String addMe)
- Adds an array of characters to the stack.
First element of the array is pushed first.
clear
public void clear()
- Removes all elements from the stack.
All Packages Class Hierarchy This Package Previous Next Index