public class ConcurrentSortedLongPairSet extends Object implements LongPairSet
LongPairSet which is not fully accurate in sorting.
ConcurrentSortedLongPairSet creates separate ConcurrentLongPairSet for unique first-key of
inserted item. So, it can iterate over all items by sorting on item's first key. However, item's second key will not
be sorted. eg:
insert: (1,2), (1,4), (2,1), (1,5), (2,6) while iterating set will first read all the entries for items whose first-key=1 and then first-key=2. output: (1,4), (1,5), (1,2), (2,6), (2,1)
This map can be expensive and not recommended if set has to store large number of unique item.first's key
because set has to create that many ConcurrentLongPairSet objects.
LongPairSet.LongPairFunction<T>, LongPairSet.LongPairPredicate| Modifier and Type | Field and Description |
|---|---|
protected NavigableMap<Long,ConcurrentLongPairSet> |
longPairSets |
| Constructor and Description |
|---|
ConcurrentSortedLongPairSet() |
ConcurrentSortedLongPairSet(int expectedItems) |
ConcurrentSortedLongPairSet(int expectedItems,
int concurrencyLevel) |
ConcurrentSortedLongPairSet(int expectedItems,
int concurrencyLevel,
int maxAllowedSetOnRemove) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(long item1,
long item2)
Adds composite value of item1 and item2 to 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)
Execute
ConcurrentLongPairSet.LongPairConsumer processor for each entry in the set. |
boolean |
isEmpty()
Check if set is empty.
|
Set<ConcurrentLongPairSet.LongPair> |
items() |
Set<ConcurrentLongPairSet.LongPair> |
items(int numberOfItems) |
<T> Set<T> |
items(int numberOfItems,
LongPairSet.LongPairFunction<T> longPairConverter) |
boolean |
remove(long item1,
long item2)
Removes composite value of item1 and item2 from set.
|
int |
removeIf(LongPairSet.LongPairPredicate filter)
Removes composite value of item1 and item2 from set if provided predicate
LongPairSet.LongPairPredicate matches. |
long |
size()
Returns size of the set.
|
String |
toString() |
protected final NavigableMap<Long,ConcurrentLongPairSet> longPairSets
public ConcurrentSortedLongPairSet()
public ConcurrentSortedLongPairSet(int expectedItems)
public ConcurrentSortedLongPairSet(int expectedItems,
int concurrencyLevel)
public ConcurrentSortedLongPairSet(int expectedItems,
int concurrencyLevel,
int maxAllowedSetOnRemove)
public boolean add(long item1,
long item2)
LongPairSetadd in interface LongPairSetpublic boolean remove(long item1,
long item2)
LongPairSetremove in interface LongPairSetpublic int removeIf(LongPairSet.LongPairPredicate filter)
LongPairSetLongPairSet.LongPairPredicate matches.removeIf in interface LongPairSetpublic Set<ConcurrentLongPairSet.LongPair> items()
items in interface LongPairSetpublic void forEach(ConcurrentLongPairSet.LongPairConsumer processor)
LongPairSetConcurrentLongPairSet.LongPairConsumer processor for each entry in the set.forEach in interface LongPairSetpublic Set<ConcurrentLongPairSet.LongPair> items(int numberOfItems)
items in interface LongPairSetpublic <T> Set<T> items(int numberOfItems, LongPairSet.LongPairFunction<T> longPairConverter)
items in interface LongPairSetlongPairConverter - converts (long,long) pair to public boolean isEmpty()
LongPairSetisEmpty in interface LongPairSetpublic void clear()
LongPairSetclear in interface LongPairSetpublic long size()
LongPairSetsize in interface LongPairSetpublic boolean contains(long item1,
long item2)
LongPairSetcontains in interface LongPairSetCopyright © 2017–2021 Apache Software Foundation. All rights reserved.