public class Stack<Item> extends Object implements Iterable<Item>
All stack operations except iteration are constant time.
For additional documentation, see Section 4.3 of Introduction to Programming in Java: An Interdisciplinary Approach by Robert Sedgewick and Kevin Wayne.
| Constructor and Description |
|---|
Stack()
Create an empty stack.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isEmpty()
Is the stack empty?
|
Iterator<Item> |
iterator()
Return an iterator to the stack that iterates through the items in LIFO order.
|
static void |
main(String[] args)
A test client.
|
Item |
peek()
Return the item most recently added to the stack.
|
Item |
pop()
Delete and return the item most recently added to the stack.
|
void |
push(Item item)
Add the item to the stack.
|
int |
size()
Return the number of items in the stack.
|
String |
toString()
Return string representation.
|
public boolean isEmpty()
public int size()
public void push(Item item)
public Item pop()
public Item peek()
public Iterator<Item> iterator()
public static void main(String[] args)
Copyright © 2014. All Rights Reserved.