Class ConcurrentLongPairSet
- java.lang.Object
-
- org.apache.pulsar.common.util.collections.ConcurrentLongPairSet
-
- All Implemented Interfaces:
LongPairSet
public class ConcurrentLongPairSet extends java.lang.Object implements 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 Classes Modifier and Type Class Description static classConcurrentLongPairSet.BuilderBuilder of ConcurrentLongPairSet.static interfaceConcurrentLongPairSet.ConsumerLongRepresents a function that accepts an object of theLongPairtype.static classConcurrentLongPairSet.LongPairClass representing two long values.static interfaceConcurrentLongPairSet.LongPairConsumerRepresents 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
Constructors Constructor Description ConcurrentLongPairSet()Deprecated.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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(long item1, long item2)Adds composite value of item1 and item2 to set.longcapacity()Returns capacity of the set.voidclear()Removes all items from set.booleancontains(long item1, long item2)Checks if given (item1,item2) composite value exists into set.voidforEach(ConcurrentLongPairSet.LongPairConsumer processor)ExecuteConcurrentLongPairSet.LongPairConsumerprocessor for each entry in the set.booleanisEmpty()Check if set is empty.java.util.Set<ConcurrentLongPairSet.LongPair>items()java.util.Set<ConcurrentLongPairSet.LongPair>items(int numberOfItems)<T> java.util.Set<T>items(int numberOfItems, LongPairSet.LongPairFunction<T> longPairConverter)static ConcurrentLongPairSet.BuildernewBuilder()booleanremove(long item1, long item2)Remove an existing entry if found.intremoveIf(LongPairSet.LongPairPredicate filter)Removes all of the elements of this collection that satisfy the given predicate.longsize()Returns size of the set.java.lang.StringtoString()
-
-
-
Constructor Detail
-
ConcurrentLongPairSet
@Deprecated public ConcurrentLongPairSet()
Deprecated.
-
ConcurrentLongPairSet
@Deprecated public ConcurrentLongPairSet(int expectedItems)
Deprecated.
-
ConcurrentLongPairSet
@Deprecated public ConcurrentLongPairSet(int expectedItems, int concurrencyLevel)Deprecated.
-
ConcurrentLongPairSet
public ConcurrentLongPairSet(int expectedItems, int concurrencyLevel, float mapFillFactor, float mapIdleFactor, boolean autoShrink, float expandFactor, float shrinkFactor)
-
-
Method Detail
-
newBuilder
public static ConcurrentLongPairSet.Builder newBuilder()
-
size
public long size()
Description copied from interface:LongPairSetReturns size of the set.- Specified by:
sizein interfaceLongPairSet- Returns:
-
capacity
public long capacity()
Description copied from interface:LongPairSetReturns capacity of the set.- Specified by:
capacityin interfaceLongPairSet- Returns:
-
isEmpty
public boolean isEmpty()
Description copied from interface:LongPairSetCheck if set is empty.- Specified by:
isEmptyin interfaceLongPairSet- Returns:
-
contains
public boolean contains(long item1, long item2)Description copied from interface:LongPairSetChecks if given (item1,item2) composite value exists into set.- Specified by:
containsin interfaceLongPairSet- Returns:
-
add
public boolean add(long item1, long item2)Description copied from interface:LongPairSetAdds composite value of item1 and item2 to set.- Specified by:
addin interfaceLongPairSet- Returns:
-
remove
public boolean remove(long item1, long item2)Remove an existing entry if found.- Specified by:
removein interfaceLongPairSet- Parameters:
item1-- Returns:
- true if removed or false if item was not present
-
clear
public void clear()
Description copied from interface:LongPairSetRemoves all items from set.- Specified by:
clearin interfaceLongPairSet
-
forEach
public void forEach(ConcurrentLongPairSet.LongPairConsumer processor)
Description copied from interface:LongPairSetExecuteConcurrentLongPairSet.LongPairConsumerprocessor for each entry in the set.- Specified by:
forEachin interfaceLongPairSet
-
removeIf
public int removeIf(LongPairSet.LongPairPredicate filter)
Removes all of the elements of this collection that satisfy the given predicate.- Specified by:
removeIfin interfaceLongPairSet- Parameters:
filter- a predicate which returnstruefor elements to be removed- Returns:
- number of removed values
-
items
public java.util.Set<ConcurrentLongPairSet.LongPair> items()
- Specified by:
itemsin interfaceLongPairSet- Returns:
- a new list of all keys (makes a copy)
-
items
public java.util.Set<ConcurrentLongPairSet.LongPair> items(int numberOfItems)
- Specified by:
itemsin interfaceLongPairSet- Returns:
- a new list of keys with max provided numberOfItems (makes a copy)
-
items
public <T> java.util.Set<T> items(int numberOfItems, LongPairSet.LongPairFunction<T> longPairConverter)- Specified by:
itemsin interfaceLongPairSetlongPairConverter- converts (long,long) pair toobject - Returns:
- a new list of keys with max provided numberOfItems
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-