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)

Variable Index

 o DEFAULT_QUEUE_SIZE

Constructor Index

 o CharStack()
Create a stack of the default size.
 o CharStack(int)
Create a stack with the given initial size.

Method Index

 o capacity()
Returns the total number of locations,, used or not, for chars in the stack
 o clear()
Removes all elements from the stack.
 o isEmpty()
Returns true is stack is empty.
 o peek()
Returns the top char on the stack.
 o pop()
Remove and return the top char on the stack.
 o push(char)
Adds a char to the top of the stack.
 o push(char[])
Adds an array of characters to the stack.
 o push(String)
Adds an array of characters to the stack.
 o toString()

Variables

 o DEFAULT_QUEUE_SIZE
 public static final int DEFAULT_QUEUE_SIZE

Constructors

 o CharStack
 public CharStack()
Create a stack of the default size.

 o CharStack
 public CharStack(int initialSize)
Create a stack with the given initial size.

Methods

 o toString
 public String toString()
Overrides:
toString in class Object
 o isEmpty
 public boolean isEmpty()
Returns true is stack is empty.

 o pop
 public char pop()
Remove and return the top char on the stack. Assumes stack is not empty.

 o peek
 public char peek()
Returns the top char on the stack. Does not remove any elements. Assumes stack is not empty.

 o capacity
 public int capacity()
Returns the total number of locations,, used or not, for chars in the stack

 o push
 public void push(char addMe)
Adds a char to the top of the stack.

 o push
 public void push(char addMe[])
Adds an array of characters to the stack. First element of the array is pushed first.

 o push
 public void push(String addMe)
Adds an array of characters to the stack. First element of the array is pushed first.

 o clear
 public void clear()
Removes all elements from the stack.


All Packages  Class Hierarchy  This Package  Previous  Next  Index