public class Stack<E> extends Object implements Seque<E>
| Constructor and Description |
|---|
Stack()
Returns an Empty
Stack. |
Stack(E top)
Returns a new
Stack with one element inserted. |
Stack(E top,
Stack<E> bottom)
Returns a new
Stack with the top and bottom supplied to it. |
| Modifier and Type | Method and Description |
|---|---|
E |
peek() |
Seque<E> |
pop()
Creates a fresh instance of Seque without the end element.
|
Seque<E> |
push(E e)
Creates a fresh instance of the Seque with the element at the open end of the
Seque.Ehis ensures immutability. |
int |
size()
Bookkeeping: Size of the collection.
|
public Stack()
Stack.public Stack(E top)
Stack with one element inserted.public Seque<E> push(E e)
SequeSeque.public Seque<E> pop()
SequeSeques are immutable, pop() is unlike traditional Stacks and Queues. It doesn't remove and give you the end element from the current Seque.peek() to gather the end element.public E peek()
public int size()
Collectionsize in interface Collection<E>Copyright © 2017. All rights reserved.