Class Stack

java.lang.Object
  |
  +--Stack

public class Stack
extends java.lang.Object

This class provides a stack that changes implementation dynamically. Initially, the implementation is an array of integers. If, during the execution of a client, the stack overflows, the array implementation is replaced by a linked list implementation.


Field Summary
private  StackImpl stack
           
 
Constructor Summary
Stack()
           
 
Method Summary
private  void copy(StackImpl from, StackImpl to)
           
(package private)  int pop()
          Pop the stack.
 void push(int val)
          Push an integer onto the stack.
(package private)  int size()
          Return the number of elements contained in the stack.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

stack

private StackImpl stack
Constructor Detail

Stack

public Stack()
Method Detail

push

public void push(int val)
Push an integer onto the stack.
Parameters:
val - The integer value pushed onto the stack.

pop

int pop()
Pop the stack.
Returns:
The integer value popped from the stack.

size

int size()
Return the number of elements contained in the stack.
Returns:
The number of elements contained in the stack.

copy

private void copy(StackImpl from,
                  StackImpl to)