edu.colorado.collections
Class CharLinkedStack

java.lang.Object
  extended by edu.colorado.collections.CharLinkedStack
All Implemented Interfaces:
java.lang.Cloneable

public class CharLinkedStack
extends java.lang.Object
implements java.lang.Cloneable

A CharLinkedStack is a stack of references to objects.

Limitations: Beyond Int.MAX_VALUE items, size is wrong.
Java Source Code for this class:
http://www.cs.colorado.edu/~main/edu/colorado/collections/CharLinkedStack.java

See Also:
CharStack, ObjectLinkedStack, BooleanLinkedStack, ByteLinkedStack, DoubleLinkedStack, FloatLinkedStack, IntLinkedStack, LongLinkedStack, ShortLinkedStack

Constructor Summary
CharLinkedStack()
          Initialize an empty stack.
 
Method Summary
 java.lang.Object clone()
          Generate a copy 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CharLinkedStack

public CharLinkedStack()
Initialize an empty stack.

Parameters:
- - none
Postcondition:
This stack is empty.
Method Detail

clone

public java.lang.Object clone()
Generate a copy of this stack.

Overrides:
clone in class java.lang.Object
Parameters:
- - none
Returns:
The return value is a copy of this stack. Subsequent changes to the copy will not affect the original, nor vice versa. Note that the return value must be type cast to a CharLinkedStack before it can be used.
Throws:
java.lang.OutOfMemoryError - Indicates insufficient memory for creating the clone.

isEmpty

public boolean isEmpty()
Determine whether this stack is empty.

Parameters:
- - none
Returns:
true if this stack is empty; false otherwise.

peek

public char peek()
Get the top item of this stack, without removing the item.

Parameters:
- - none
Precondition:
This stack is not empty.
Returns:
the top item of the stack
Throws:
java.util.EmptyStackException - Indicates that this stack is empty.

pop

public char pop()
Get the top item, removing it from this stack.

Parameters:
- - none
Precondition:
This stack is not empty.
Postcondition:
The return value is the top item of this stack, and the item has been removed.
Throws:
java.util.EmptyStackException - Indicates that this stack is empty.

push

public void push(char item)
Push a new item onto this stack. The new item may be the null reference.

Parameters:
item - the item to be pushed onto this stack
Postcondition:
The item has been pushed onto this stack.
Throws:
java.lang.OutOfMemoryError - Indicates insufficient memory for increasing the stack's capacity.

size

public int size()
Accessor method to determine the number of items in this stack.

Parameters:
- - none
Returns:
the number of items in this stack