|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> java.util.AbstractList<E> org.amino.ds.lockfree.LockFreeVector<E>
E
- type of element in the vectorpublic class LockFreeVector<E>
It is a thread safe and lock-free vector. This class implement algorithm
from:
"Lock-free Dynamically Resizable Arrays"
Damian Dechev, Peter Pirkelbauer, and Bjarne Stroustrup
Texas A&M University College Station, TX 77843-3112
{dechev, peter.pirkelbauer}@tamu.edu, bs@cs.tamu.edu
This vector supports dynamic expansion of vector in a lock-free manner. The
elements are stored in an array of segments. The fist segment (with an index
of '0') can contain 8 elements. See FIRST_BUCKET_SIZE
. The nth
segment can contain 8*(2**n) elements.
Field Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
LockFreeVector()
Create a new lock-free vector. |
Method Summary | |
---|---|
boolean |
add(E object)
|
E |
get(int index)
Get element with the index. |
E |
popBack()
Remove the last element in the vector. |
void |
pushBack(E e)
add e at the end of vector. |
void |
reserve(int newSize)
reserve more space. |
E |
set(int index,
E e)
Set the element with index to e. |
int |
size()
return size of vector. |
Methods inherited from class java.util.AbstractList |
---|
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
Constructor Detail |
---|
public LockFreeVector()
Method Detail |
---|
public void pushBack(E e)
e
- element addedpublic E popBack()
public E get(int index)
get
in interface java.util.List<E>
get
in class java.util.AbstractList<E>
index
- index
public E set(int index, E e)
set
in interface java.util.List<E>
set
in class java.util.AbstractList<E>
index
- index of element to be resete
- element to set
public void reserve(int newSize)
newSize
- new size be reservedpublic int size()
size
in interface java.util.Collection<E>
size
in interface java.util.List<E>
size
in class java.util.AbstractCollection<E>
public boolean add(E object)
add
in interface java.util.Collection<E>
add
in interface java.util.List<E>
add
in class java.util.AbstractList<E>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |