| Constructor and Description |
|---|
LazyStack() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
empty()
Tests if this stack is empty.
|
Optional<T> |
peek()
Looks at the object at the top of this stack without removing it from the stack.
|
Optional<T> |
pop()
Removes the object at the top of this stack and returns an Optional of that object as the value of this function.
|
T |
push(T item)
Pushes an item onto the top of this stack.
|
int |
search(Object o)
Returns the 1-based position where an object is on this stack.
|
public T push(T item)
item - the item to be pushed onto this stackitem argumentStack.push(Object)public Optional<T> pop()
Optional with the object at the top of this stack if exists, or Optional.EMPTY
otherwisepublic Optional<T> peek()
Optional with the object at the top of this stack if exists, or Optional.EMPTY
otherwisepublic boolean empty()
true if and only if this stack contains no items; false otherwise.public int search(Object o)
If the object o occurs as an item in this stack, this method returns the distance from the top of the stack of the occurrence nearest the top of the stack; the topmost item on the stack is considered to be at distance 1. The equals method is used to compare o to the items in this stack.
o - the desired object.-1 indicates that the object is not on the stack.Copyright © 2016–2019 AdroitLogic. All rights reserved.