E - type of stack entries@ThreadSafe final class ConcurrentStack<E> extends Object implements Stack<E>
Implemented with a linked list.
TOP Node_0 Node_1 Node_2 Node_3 Node_4
null next-> next-> next-> next-> null
| Modifier and Type | Class and Description |
|---|---|
private static class |
ConcurrentStack.Entry<T>
Linked list entry.
|
| Modifier and Type | Field and Description |
|---|---|
private AtomicReference<ConcurrentStack.Entry<E>> |
top
References the top of the stack.
|
| Constructor and Description |
|---|
ConcurrentStack() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
int |
hashCode() |
boolean |
isEmpty()
Check if stack is empty.
|
E |
peek()
Returns the top element of stack w/o remove it.
|
E |
pop()
Returns the top element of stack and removes it.
|
void |
push(E element)
Push entry on top of the stack.
|
String |
toString() |
private final AtomicReference<ConcurrentStack.Entry<E>> top
public boolean isEmpty()
Stackpublic E peek()
Stackpublic E pop()
Stackpublic void push(E element)
StackCopyright © 2014 Sven Strittmatter. All Rights Reserved.