Constructor and Description |
---|
LinkedStack()
Constructs an empty stack.
|
Modifier and Type | Method and Description |
---|---|
boolean |
empty()
Returns true if the stack is empty; otherwise returns false.
|
Iterator<T> |
iterator()
Iterates over the items in this LinkedStack, starting
at the top of the stack and working its way down.
|
T |
peek()
Looks at the object at the top of this stack without removing it from the stack.
|
T |
pop()
Removes the object at the top of this stack and returns that object as the value of this function.
|
T |
push(T item)
Pushes an item onto the top of this stack and returns it.
|
int |
search(Object o)
Returns the 1-based position where an object is on this stack.
|
int |
size()
Returns the size of this stack.
|
forEach, spliterator
public LinkedStack()
no this.elems'
public boolean empty()
public Iterator<T> iterator()
public T peek()
peek
in class Stack<T>
EmptyStackException
- no this.elemspublic T pop()
pop
in class Stack<T>
this.size' = this.size - 1 &&
all i: [1..this.size) | this.elems'[i-1] = this.elems[i]
EmptyStackException
- no this.elemspublic int search(Object o)
public int size()
Stack
size
in class Stack<T>
Stack.size()
© Emina Torlak 2005-present