Stack
A simple stack abstraction, backed by linked list.
stack<Type>
Subtypes | Supertypes | Comparable types |
---|---|---|
deque<Type> | sequence<Type> | java.util.Deque<Type> |
new linkedlist
Parameter type | Result type |
---|---|
Type... sequence<? extends Type> | stack<Type> |
Creates an empty stack. Optionally, initial values may be specified right in the new linked list creation expression.
stack<string> test = new linkedlist<string> {"A", "B", "C"};
Alternatively, a sequence may be specified that is used to copy elements from.
stack<Type> = new linkedlist<Type> (sequence);
Operand type | Parameter type | Result type |
---|---|---|
sequence<Type> | none | modifying_iterator<Type> |
This operation is redefined for stack to return a modifying_iterator
.
Operand type | Parameter type | Result type |
---|---|---|
stack<Type> | Type | Type |
Appends an element to the head of the stack.
set.addFirst (value);
set.push (value);
Operand type | Parameter type | Result type |
---|---|---|
stack<Type> | Type |
Removes an element from the head of the stack.
set.removeFirst (value);
set.pop (value);
Operand type | Parameter type | Result type |
---|---|---|
stack<Type> | Type |
Retrieves the first element at the head of the stack without removing it.
set.first ();
set.peek ();
Thanks for your feedback!