public class ByteLinkedStack
extends java.lang.Object
implements java.lang.Cloneable
ByteLinkedStack
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/ByteLinkedStack.java
Constructor and Description |
---|
ByteLinkedStack()
Initialize an empty stack.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Generate a copy of this stack.
|
boolean |
isEmpty()
Determine whether this stack is empty.
|
byte |
peek()
Get the top item of this stack, without removing the item.
|
byte |
pop()
Get the top item, removing it from this stack.
|
void |
push(byte item)
Push a new item onto this stack.
|
int |
size()
Accessor method to determine the number of items in this stack.
|
public ByteLinkedStack()
public java.lang.Object clone()
clone
in class java.lang.Object
ByteLinkedStack
before it can be used.java.lang.OutOfMemoryError
- Indicates insufficient memory for creating the clone.public boolean isEmpty()
true
if this stack is empty;
false
otherwise.public byte peek()
java.util.EmptyStackException
- Indicates that this stack is empty.public byte pop()
java.util.EmptyStackException
- Indicates that this stack is empty.public void push(byte item)
item
- the item to be pushed onto this stack
Postcondition:
The item has been pushed onto this stack.java.lang.OutOfMemoryError
- Indicates insufficient memory for increasing the stack's capacity.public int size()