org.semanticweb.elk.util.concurrent.collections
Class ActivationStack<E>
java.lang.Object
org.semanticweb.elk.util.concurrent.collections.ActivationStack<E>
- Type Parameters:
E - the type of elements in the stack
public class ActivationStack<E>
- extends Object
A thread-safe implementation of stack based on the non-blocking Treiber's
Algorithm (Treiber, 1986). The implementation allows to check when the pushed
element is the first element in the stack. This stack does not allow storing
null values.
- Author:
- "Yevgeny Kazakov"
|
Method Summary |
E |
peek()
|
E |
pop()
Takes and removes the head element of the stack. |
boolean |
push(E element)
Inserts the given element at the head of the stack. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ActivationStack
public ActivationStack()
push
public boolean push(E element)
- Inserts the given element at the head of the stack. Returns
true
if this is the first element inserted after the stack has been cleared. A
stack is cleared after it has been constructed or after pop()
returns null. Note that the stack might be empty in the sense
that the next call to pop() should return null, but not
cleared. In this case the stack is cleared only after pop()
returns null.
- Parameters:
element -
- Returns:
true if this is the first element inserted after the
stack has been cleared.
- Throws:
IllegalArgumentException - if null element is inserted
peek
public E peek()
pop
public E pop()
- Takes and removes the head element of the stack.
- Returns:
- the head element in the stack or
null if there are no
elements in the stack
Copyright © 2011-2013 Department of Computer Science, University of Oxford. All Rights Reserved.