Package org.jctools.sets
Class SingleWriterHashSet<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- org.jctools.sets.SingleWriterHashSet<E>
-
- All Implemented Interfaces:
java.lang.Iterable<E>,java.util.Collection<E>,java.util.Set<E>
public class SingleWriterHashSet<E> extends java.util.AbstractSet<E>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classSingleWriterHashSet.Iter<E>
-
Field Summary
Fields Modifier and Type Field Description private E[]bufferprivate static longBUFFER_OFFSETprivate static longMC_OFFSETprivate longmodCountprivate intresizeThresholdprivate intsizeprivate static longSIZE_OFFSET
-
Constructor Summary
Constructors Constructor Description SingleWriterHashSet(int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E newVal)private voidaddForResize(E[] buffer, long mask, E newVal)private booleanaddSlowPath(E[] buffer, long mask, E newVal, int hash)private voidcompactAndRemove(E[] buffer, long mask, int removeHashIndex)booleancontains(java.lang.Object needle)private booleancontainsImpl(java.lang.Object needle)private booleancontainsSlowPath(E[] buffer, long mask, int hash, java.lang.Object needle)java.util.Iterator<E>iterator()private E[]lvBuffer()private intrehash(int h)booleanremove(java.lang.Object val)private booleanremoveSlowPath(java.lang.Object val, E[] buffer, long mask, int hash)private voidresize()intsize()private voidsoBuffer(E[] buffer)java.lang.StringtoString()-
Methods inherited from class java.util.AbstractCollection
addAll, clear, containsAll, isEmpty, retainAll, toArray, toArray
-
-
-
-
Field Detail
-
size
private int size
-
modCount
private long modCount
-
buffer
private E[] buffer
-
resizeThreshold
private int resizeThreshold
-
BUFFER_OFFSET
private static final long BUFFER_OFFSET
-
SIZE_OFFSET
private static final long SIZE_OFFSET
-
MC_OFFSET
private static final long MC_OFFSET
-
-
Method Detail
-
size
public int size()
-
add
public boolean add(E newVal)
-
resize
private void resize()
-
remove
public boolean remove(java.lang.Object val)
-
removeSlowPath
private boolean removeSlowPath(java.lang.Object val, E[] buffer, long mask, int hash)
-
compactAndRemove
private void compactAndRemove(E[] buffer, long mask, int removeHashIndex)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.util.AbstractCollection<E>
-
rehash
private int rehash(int h)
-
contains
public boolean contains(java.lang.Object needle)
-
containsImpl
private boolean containsImpl(java.lang.Object needle)
-
containsSlowPath
private boolean containsSlowPath(E[] buffer, long mask, int hash, java.lang.Object needle)
-
iterator
public java.util.Iterator<E> iterator()
-
soBuffer
private void soBuffer(E[] buffer)
-
lvBuffer
private E[] lvBuffer()
-
-