Class ConcurrentLongHashSet
Provides similar methods as a ConcurrentSet<Long> but since it's an open hash map with linear probing, no node allocations are required to store the values.
Items MUST be >= 0.
WARN: method forEach do not guarantee thread safety, nor does the items method.
The forEach method is specifically designed for single-threaded usage. When iterating over a set
with concurrent writes, it becomes possible for new values to be either observed or not observed.
There is no guarantee that if we write value1 and value2, and are able to see value2, then we will also see value1.
It is crucial to understand that the results obtained from aggregate status methods such as items
are typically reliable only when the map is not undergoing concurrent updates from other threads.
When concurrent updates are involved, the results of these methods reflect transient states
that may be suitable for monitoring or estimation purposes, but not for program control.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder of ConcurrentLongHashSet.static interfaceA consumer of long values. -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.ConcurrentLongHashSet(int expectedItems) Deprecated.ConcurrentLongHashSet(int expectedItems, int concurrencyLevel) Deprecated.ConcurrentLongHashSet(int expectedItems, int concurrencyLevel, float mapFillFactor, float mapIdleFactor, boolean autoShrink, float expandFactor, float shrinkFactor) -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(long item) longcapacity()voidclear()booleancontains(long item) voidforEach(ConcurrentLongHashSet.ConsumerLong processor) (package private) long(package private) static final longhash(long key) booleanisEmpty()items()booleanremove(long item) Remove an existing entry if found.(package private) static final intsignSafeMod(long n, int max) longsize()long
-
Constructor Details
-
ConcurrentLongHashSet
Deprecated. -
ConcurrentLongHashSet
Deprecated. -
ConcurrentLongHashSet
Deprecated. -
ConcurrentLongHashSet
public ConcurrentLongHashSet(int expectedItems, int concurrencyLevel, float mapFillFactor, float mapIdleFactor, boolean autoShrink, float expandFactor, float shrinkFactor)
-
-
Method Details
-
newBuilder
-
size
public long size() -
sizeInBytes
public long sizeInBytes() -
capacity
public long capacity() -
isEmpty
public boolean isEmpty() -
getUsedBucketCount
long getUsedBucketCount() -
contains
public boolean contains(long item) -
add
public boolean add(long item) -
remove
public boolean remove(long item) Remove an existing entry if found.- Parameters:
item-- Returns:
- true if removed or false if item was not present
-
clear
public void clear() -
forEach
-
items
- Returns:
- a new list of all keys (makes a copy)
-
hash
static final long hash(long key) -
signSafeMod
static final int signSafeMod(long n, int max)
-