Stack
Stack
A simple stack abstraction, backed by linked list.
Stack type
stack<Type>
| Subtypes | Supertypes | Comparable types |
|---|---|---|
| deque<Type> | sequence<Type> | java.util.Deque<Type> |
Stack creation
new linkedlist| Parameter type | Result type |
|---|---|
| Type... | stack<Type> |
Creates an empty stack. Optionally, initial values may be specified right in the new linked list creation expression.
Alternatively, a sequence may be specified that is used to copy elements from.
Operations on stack
iterator
| Operand type | Parameter type | Result type |
|---|---|---|
| sequence<Type> | none | modifying_iterator<Type> |
This operation is redefined for stack to return a modifying_iterator .
addFirst / push
| Operand type | Parameter type | Result type |
|---|---|---|
| stack<Type> | Type | Type |
Appends an element to the head of the stack.
removeFirst / pop
| Operand type | Parameter type | Result type |
|---|---|---|
| stack<Type> |
| Type |
Removes an element from the head of the stack.
first / peek
| Operand type | Parameter type | Result type |
|---|---|---|
| stack<Type> |
| Type |
Retrieves the first element at the head of the stack without removing it.