|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.amino.ds.lockfree.LockFreeList<E>
E - the type of elements held in this collectionpublic class LockFreeList<E>
This is an implementation of a lock-free linked list data structure. The implementation is according to the paper High Performance Dynamic Lock-Free Hash Tables and List-Based Sets by Maged M. Michael, 2002. To gain a complete understanding of this data structure, please first read this paper, available at: http://www.research.ibm.com/people/m/michael/spaa-2002.pdf
This lock-free linked list is an unbounded thread-safe linked list. A LockFreeList is an appropriate choice when many threads will share access to a common collection. This list does not permit null elements.
This is a lock-free implementation intended for highly scalable add, remove and contains which is thread safe. All method related to index is not implemented. Add() will add the element to the head of the list which is different with the normal list.
| Nested Class Summary | |
|---|---|
protected static class |
LockFreeList.Entry<E>
internal node definition. |
protected static class |
LockFreeList.ListStateHolder<E>
hold state between two function calls. |
| Field Summary | |
|---|---|
protected java.util.concurrent.atomic.AtomicMarkableReference<LockFreeList.Entry<E>> |
head
Pointer to header node, initialized to a dummy node. |
| Constructor Summary | |
|---|---|
LockFreeList()
Constructs an empty list. |
|
| Method Summary | ||
|---|---|---|
boolean |
add(E e)
Adds the specified element to the head of this list. |
|
void |
add(int index,
E element)
|
|
boolean |
addAll(java.util.Collection<? extends E> c)
|
|
boolean |
addAll(int index,
java.util.Collection<? extends E> c)
|
|
void |
clear()
Removes all of the elements from this list (optional operation). |
|
boolean |
contains(java.lang.Object o)
Returns true if this list contains the specified element. |
|
boolean |
containsAll(java.util.Collection<?> c)
|
|
E |
get(int index)
|
|
int |
indexOf(java.lang.Object o)
|
|
boolean |
isEmpty()
|
|
java.util.Iterator<E> |
iterator()
|
|
int |
lastIndexOf(java.lang.Object o)
|
|
java.util.ListIterator<E> |
listIterator()
|
|
java.util.ListIterator<E> |
listIterator(int index)
|
|
E |
remove(int index)
|
|
boolean |
remove(java.lang.Object o)
|
|
boolean |
removeAll(java.util.Collection<?> c)
|
|
boolean |
retainAll(java.util.Collection<?> c)
|
|
E |
set(int index,
E element)
|
|
int |
size()
|
|
java.util.List<E> |
subList(int fromIndex,
int toIndex)
|
|
java.lang.Object[] |
toArray()
|
|
|
toArray(T[] a)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.List |
|---|
equals, hashCode |
| Field Detail |
|---|
protected java.util.concurrent.atomic.AtomicMarkableReference<LockFreeList.Entry<E>> head
| Constructor Detail |
|---|
public LockFreeList()
| Method Detail |
|---|
public boolean add(E e)
Thread Safe
add in interface java.util.Collection<E>add in interface java.util.List<E>e - the element to add.
public void clear()
Thread Safe
clear in interface java.util.Collection<E>clear in interface java.util.List<E>public boolean contains(java.lang.Object o)
Thread Safe
contains in interface java.util.Collection<E>contains in interface java.util.List<E>o - element whose presence in this list is to be tested.
public boolean isEmpty()
Thread Safe
isEmpty in interface java.util.Collection<E>isEmpty in interface java.util.List<E>public boolean remove(java.lang.Object o)
Thread Safe
remove in interface java.util.Collection<E>remove in interface java.util.List<E>public java.util.Iterator<E> iterator()
Not Thread Safe
iterator in interface java.lang.Iterable<E>iterator in interface java.util.Collection<E>iterator in interface java.util.List<E>public int size()
Not Thread Safe
size in interface java.util.Collection<E>size in interface java.util.List<E>
public void add(int index,
E element)
add in interface java.util.List<E>
public boolean addAll(int index,
java.util.Collection<? extends E> c)
addAll in interface java.util.List<E>public E get(int index)
get in interface java.util.List<E>public int indexOf(java.lang.Object o)
indexOf in interface java.util.List<E>public int lastIndexOf(java.lang.Object o)
lastIndexOf in interface java.util.List<E>public java.util.ListIterator<E> listIterator()
listIterator in interface java.util.List<E>public java.util.ListIterator<E> listIterator(int index)
listIterator in interface java.util.List<E>public E remove(int index)
remove in interface java.util.List<E>public boolean removeAll(java.util.Collection<?> c)
removeAll in interface java.util.Collection<E>removeAll in interface java.util.List<E>public boolean retainAll(java.util.Collection<?> c)
retainAll in interface java.util.Collection<E>retainAll in interface java.util.List<E>
public E set(int index,
E element)
set in interface java.util.List<E>
public java.util.List<E> subList(int fromIndex,
int toIndex)
subList in interface java.util.List<E>public java.lang.Object[] toArray()
toArray in interface java.util.Collection<E>toArray in interface java.util.List<E>public <T> T[] toArray(T[] a)
toArray in interface java.util.Collection<E>toArray in interface java.util.List<E>public boolean addAll(java.util.Collection<? extends E> c)
addAll in interface java.util.Collection<E>addAll in interface java.util.List<E>public boolean containsAll(java.util.Collection<?> c)
containsAll in interface java.util.Collection<E>containsAll in interface java.util.List<E>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||