|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.amino.ds.lockfree.LockFreeSet<E>
E
- Type of elements stored in the setpublic class LockFreeSet<E>
This is an implementation of lock-free hashset data structure, based on algorithm described in two paper
LockFreeOrderedList
. Elements are sorted by
"binary reversal" of hash of elements. Additionally, an array of dummy nodes
is stored to allow quick access to elements in the middle of elements.
Elements are wrapped by HashLinkNode
before stored into set.
Constructor Summary | |
---|---|
LockFreeSet()
Create a new LockFreeSet. |
|
LockFreeSet(int expectedSize)
|
|
LockFreeSet(int expectedSize,
float loadFactor)
Create a new set with explicitly specified expected size and load factor. |
Method Summary | ||
---|---|---|
boolean |
add(E e)
|
|
boolean |
addAll(java.util.Collection<? extends E> c)
|
|
void |
clear()
|
|
boolean |
contains(java.lang.Object o)
|
|
boolean |
containsAll(java.util.Collection<?> c)
|
|
boolean |
isEmpty()
|
|
java.util.Iterator<E> |
iterator()
|
|
boolean |
remove(java.lang.Object o)
|
|
boolean |
removeAll(java.util.Collection<?> c)
|
|
boolean |
retainAll(java.util.Collection<?> c)
This method is not thread-safe. |
|
int |
size()
|
|
java.lang.Object[] |
toArray()
This method puts all elements of set into an array and returns it. |
|
|
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.Set |
---|
equals, hashCode |
Constructor Detail |
---|
public LockFreeSet(int expectedSize, float loadFactor)
512*expectedSize
.
This isn't a limitation of actual elements stored in set. But the average
search number will increase if number of elements is bigger than
512*expectedSize
expectedSize
- the estimated size of setloadFactor
- average load factor. Number of dummy nodes will expand 2X if
the actual load factor is higher than this parameter.public LockFreeSet(int expectedSize)
expectedSize
- expected set size.public LockFreeSet()
Method Detail |
---|
public boolean add(E e)
add
in interface java.util.Collection<E>
add
in interface java.util.Set<E>
public boolean addAll(java.util.Collection<? extends E> c)
addAll
in interface java.util.Collection<E>
addAll
in interface java.util.Set<E>
public void clear()
clear
in interface java.util.Collection<E>
clear
in interface java.util.Set<E>
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<E>
contains
in interface java.util.Set<E>
public boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<E>
containsAll
in interface java.util.Set<E>
public boolean isEmpty()
isEmpty
in interface java.util.Collection<E>
isEmpty
in interface java.util.Set<E>
public java.util.Iterator<E> iterator()
iterator
in interface java.lang.Iterable<E>
iterator
in interface java.util.Collection<E>
iterator
in interface java.util.Set<E>
public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection<E>
remove
in interface java.util.Set<E>
public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<E>
removeAll
in interface java.util.Set<E>
public boolean retainAll(java.util.Collection<?> c)
retainAll
in interface java.util.Collection<E>
retainAll
in interface java.util.Set<E>
c
- collection containing elements to be retained in this set
public int size()
size
in interface java.util.Collection<E>
size
in interface java.util.Set<E>
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<E>
toArray
in interface java.util.Set<E>
public <T> T[] toArray(T[] a)
toArray
in interface java.util.Collection<E>
toArray
in interface java.util.Set<E>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |