Class ConcurrentLongPairSet
java.lang.Object
org.apache.pulsar.common.util.collections.ConcurrentLongPairSet
- All Implemented Interfaces:
LongPairSet
Concurrent hash set where values are composed of pairs of longs.
Provides similar methods as a ConcurrentHashSet<V>
but since it's an open hash set with linear probing,
no node allocations are required to store the keys and values, and no boxing is required.
Values MUST be >= 0.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Builder of ConcurrentLongPairSet.static interface
Represents a function that accepts an object of theLongPair
type.static class
Class representing two long values.static interface
Represents a function that accepts two long arguments.Nested classes/interfaces inherited from interface org.apache.pulsar.common.util.collections.LongPairSet
LongPairSet.LongPairFunction<T>, LongPairSet.LongPairPredicate
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.ConcurrentLongPairSet
(int expectedItems) Deprecated.ConcurrentLongPairSet
(int expectedItems, int concurrencyLevel) Deprecated.ConcurrentLongPairSet
(int expectedItems, int concurrencyLevel, float mapFillFactor, float mapIdleFactor, boolean autoShrink, float expandFactor, float shrinkFactor) -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(long item1, long item2) Adds composite value of item1 and item2 to set.long
capacity()
Returns capacity of the set.void
clear()
Removes all items from set.boolean
contains
(long item1, long item2) Checks if given (item1,item2) composite value exists into set.void
forEach
(ConcurrentLongPairSet.LongPairConsumer processor) ExecuteConcurrentLongPairSet.LongPairConsumer
processor for each entry in the set.boolean
isEmpty()
Check if set is empty.items()
items
(int numberOfItems) <T> Set<T>
items
(int numberOfItems, LongPairSet.LongPairFunction<T> longPairConverter) boolean
remove
(long item1, long item2) Remove an existing entry if found.int
Removes all of the elements of this collection that satisfy the given predicate.long
size()
Returns size of the set.toString()
-
Constructor Details
-
ConcurrentLongPairSet
Deprecated. -
ConcurrentLongPairSet
Deprecated. -
ConcurrentLongPairSet
Deprecated. -
ConcurrentLongPairSet
public ConcurrentLongPairSet(int expectedItems, int concurrencyLevel, float mapFillFactor, float mapIdleFactor, boolean autoShrink, float expandFactor, float shrinkFactor)
-
-
Method Details
-
newBuilder
-
size
public long size()Description copied from interface:LongPairSet
Returns size of the set.- Specified by:
size
in interfaceLongPairSet
- Returns:
-
capacity
public long capacity()Description copied from interface:LongPairSet
Returns capacity of the set.- Specified by:
capacity
in interfaceLongPairSet
- Returns:
-
isEmpty
public boolean isEmpty()Description copied from interface:LongPairSet
Check if set is empty.- Specified by:
isEmpty
in interfaceLongPairSet
- Returns:
-
contains
public boolean contains(long item1, long item2) Description copied from interface:LongPairSet
Checks if given (item1,item2) composite value exists into set.- Specified by:
contains
in interfaceLongPairSet
- Returns:
-
add
public boolean add(long item1, long item2) Description copied from interface:LongPairSet
Adds composite value of item1 and item2 to set.- Specified by:
add
in interfaceLongPairSet
- Returns:
-
remove
public boolean remove(long item1, long item2) Remove an existing entry if found.- Specified by:
remove
in interfaceLongPairSet
- Parameters:
item1
-- Returns:
- true if removed or false if item was not present
-
clear
public void clear()Description copied from interface:LongPairSet
Removes all items from set.- Specified by:
clear
in interfaceLongPairSet
-
forEach
Description copied from interface:LongPairSet
ExecuteConcurrentLongPairSet.LongPairConsumer
processor for each entry in the set.- Specified by:
forEach
in interfaceLongPairSet
-
removeIf
Removes all of the elements of this collection that satisfy the given predicate.- Specified by:
removeIf
in interfaceLongPairSet
- Parameters:
filter
- a predicate which returnstrue
for elements to be removed- Returns:
- number of removed values
-
items
- Specified by:
items
in interfaceLongPairSet
- Returns:
- a new list of all keys (makes a copy)
-
items
- Specified by:
items
in interfaceLongPairSet
- Returns:
- a new list of keys with max provided numberOfItems (makes a copy)
-
items
- Specified by:
items
in interfaceLongPairSet
longPairConverter
- converts (long,long) pair toobject - Returns:
- a new list of keys with max provided numberOfItems
-
toString
-