Class LongHashSet
java.lang.Object
org.greenrobot.essentials.collections.LongHashSet
- Direct Known Subclasses:
LongHashSet.Synchronized
An 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 ClassesModifier and TypeClassDescription(package private) static final class
protected static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
protected static final int
private float
private int
private LongHashSet.Entry[]
private int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(long key) Adds the given value to the set.void
clear()
boolean
contains
(long key) static LongHashSet
Creates a synchronized (thread-safe) LongHashSet.static LongHashSet
createSynchronized
(int capacity) Creates a synchronized (thread-safe) LongHashSet using the given initial capacity.long[]
keys()
Returns all keys in no particular order.boolean
remove
(long key) Removes the given value to the set.void
reserveRoom
(int entryCount) Target load: 0,6void
setCapacity
(int newCapacity) void
setLoadFactor
(float loadFactor) int
size()
-
Field Details
-
DEFAULT_CAPACITY
protected static final int DEFAULT_CAPACITY- See Also:
-
table
-
capacity
private int capacity -
threshold
private int threshold -
size
private volatile int size -
loadFactor
private volatile float loadFactor
-
-
Constructor Details
-
LongHashSet
public LongHashSet() -
LongHashSet
public LongHashSet(int capacity)
-
-
Method Details
-
createSynchronized
Creates a synchronized (thread-safe) LongHashSet. -
createSynchronized
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
-