Class LongHashSet
- java.lang.Object
-
- org.greenrobot.essentials.collections.LongHashSet
-
- Direct Known Subclasses:
LongHashSet.Synchronized
public class LongHashSet extends java.lang.ObjectAn minimalistic hash set optimized for long values. The default implementation is not thread-safe, but you can get a synchronized variant using one of the static createSynchronized methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classLongHashSet.Entryprotected static classLongHashSet.Synchronized
-
Field Summary
Fields Modifier and Type Field Description private intcapacityprotected static intDEFAULT_CAPACITYprivate floatloadFactorprivate intsizeprivate LongHashSet.Entry[]tableprivate intthreshold
-
Constructor Summary
Constructors Constructor Description LongHashSet()LongHashSet(int capacity)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(long key)Adds the given value to the set.voidclear()booleancontains(long key)static LongHashSetcreateSynchronized()Creates a synchronized (thread-safe) LongHashSet.static LongHashSetcreateSynchronized(int capacity)Creates a synchronized (thread-safe) LongHashSet using the given initial capacity.long[]keys()Returns all keys in no particular order.booleanremove(long key)Removes the given value to the set.voidreserveRoom(int entryCount)Target load: 0,6voidsetCapacity(int newCapacity)voidsetLoadFactor(float loadFactor)intsize()
-
-
-
Field Detail
-
DEFAULT_CAPACITY
protected static final int DEFAULT_CAPACITY
- See Also:
- Constant Field Values
-
table
private LongHashSet.Entry[] table
-
capacity
private int capacity
-
threshold
private int threshold
-
size
private volatile int size
-
loadFactor
private volatile float loadFactor
-
-
Method Detail
-
createSynchronized
public static LongHashSet createSynchronized()
Creates a synchronized (thread-safe) LongHashSet.
-
createSynchronized
public static LongHashSet createSynchronized(int capacity)
Creates a synchronized (thread-safe) LongHashSet using the given initial capacity.
-
contains
public boolean contains(long key)
-
add
public boolean add(long key)
Adds the given value to the set.- Returns:
- true if the value was actually new
-
remove
public boolean remove(long key)
Removes the given value to the set.- Returns:
- true if the value was actually removed
-
keys
public long[] keys()
Returns all keys in no particular order.
-
clear
public void clear()
-
size
public int size()
-
setCapacity
public void setCapacity(int newCapacity)
-
setLoadFactor
public void setLoadFactor(float loadFactor)
-
reserveRoom
public void reserveRoom(int entryCount)
Target load: 0,6
-
-