Package edu.hws.jcm.data
Class StackOfDouble
- java.lang.Object
-
- edu.hws.jcm.data.StackOfDouble
-
- All Implemented Interfaces:
java.io.Serializable
public class StackOfDouble extends java.lang.Object implements java.io.Serializable
A standard stack of values of type double, which can grow to arbitrary size.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StackOfDouble()
Create an initially empty stack.StackOfDouble(int initialSize)
Create an empty stack that initially has space for initialSize items pre-allocated.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isEmpty()
Return true if and only if the stack contains no items.void
makeEmpty()
Clear all items from the stack.double
pop()
Remove and return the top item on the stack.void
push(double x)
Add x to top of stack.int
size()
Return the number of items on the stack.
-
-
-
Constructor Detail
-
StackOfDouble
public StackOfDouble()
Create an initially empty stack. It initially has space allocated for one item.
-
StackOfDouble
public StackOfDouble(int initialSize)
Create an empty stack that initially has space for initialSize items pre-allocated. If initialSize <= 0, an initialSize of 1 is used.
-
-
Method Detail
-
push
public void push(double x)
Add x to top of stack.
-
pop
public double pop()
Remove and return the top item on the stack. Will throw an exception of type java.util.EmptyStackException if the stack is empty when pop() is called.
-
isEmpty
public boolean isEmpty()
Return true if and only if the stack contains no items.
-
makeEmpty
public void makeEmpty()
Clear all items from the stack.
-
size
public int size()
Return the number of items on the stack.
-
-