public interface IMultiLookup<Key,Value>
Implementors must provide semantic (not identity-based) hashCode() and equals() using the static helpers hashCode(IMultiLookup)
and equals(IMultiLookup, Object)
here.
Modifier and Type | Interface and Description |
---|---|
static class |
IMultiLookup.ChangeGranularity
How significant was the change? *
|
Modifier and Type | Method and Description |
---|---|
IMultiLookup.ChangeGranularity |
addPair(Key key,
Value value)
Adds key-value pair to the lookup structure, or fails if not possible.
|
IMultiLookup.ChangeGranularity |
addPairOrNop(Key key,
Value value)
Adds key-value pair to the lookup structure.
|
IMultiLookup.ChangeGranularity |
addPairPositiveMultiplicity(Key key,
Value value,
int count)
Updates multiplicity of key-value pair by a positive amount.
|
void |
clear()
Empties out the lookup structure.
|
int |
countKeys() |
java.lang.Iterable<Key> |
distinctKeys() |
java.util.stream.Stream<Key> |
distinctKeysStream() |
java.lang.Iterable<Value> |
distinctValues()
Iterates once over each distinct value.
|
java.util.stream.Stream<Value> |
distinctValuesStream()
Iterates once over each distinct value.
|
static <Key,Value> |
equals(IMultiLookup<Key,Value> self,
java.lang.Object obj)
Provides semantic equality comparison.
|
static <Key,Value> |
hashCode(IMultiLookup<Key,Value> memory)
Provides semantic hashCode() comparison.
|
boolean |
isEmpty()
Returns true if this collection is empty, false otherwise.
|
IMemoryView<Value> |
lookup(Key key)
Returns a (read-only) bucket of values associated with the given key.
|
IMemoryView<Value> |
lookupAndRemoveAll(Key key)
Returns a (read-only) bucket of values associated with the given key, while simultaneously removing them.
|
boolean |
lookupExists(Key key)
Returns true if there are any values associated with the given key.
|
default IMemoryView<Value> |
lookupOrEmpty(Key key)
Returns a (read-only) bucket of values associated with the given key.
|
IMemoryView<Value> |
lookupUnsafe(java.lang.Object key)
Returns a (read-only) bucket of values associated with the given key, which can be of any type.
|
default IMemoryView<Value> |
lookupUnsafeOrEmpty(java.lang.Object key)
Returns a (read-only) bucket of values associated with the given key.
|
IMultiLookup.ChangeGranularity |
removePair(Key key,
Value value)
Removes key-value pair from the lookup structure, or fails if not possible.
|
IMultiLookup.ChangeGranularity |
removePairOrNop(Key key,
Value value)
Removes key-value pair from the lookup structure.
|
boolean isEmpty()
boolean lookupExists(Key key)
key
- a key for which associated values are soughtIMemoryView<Value> lookup(Key key)
key
- a key for which associated values are soughtdefault IMemoryView<Value> lookupOrEmpty(Key key)
key
- a key for which associated values are soughtIMemoryView<Value> lookupAndRemoveAll(Key key)
key
- a key for which associated values are soughtIMemoryView<Value> lookupUnsafe(java.lang.Object key)
key
- a key for which associated values are sought (may or may not be of Key type)default IMemoryView<Value> lookupUnsafeOrEmpty(java.lang.Object key)
key
- a key for which associated values are sought (may or may not be of Key type)java.lang.Iterable<Key> distinctKeys()
java.util.stream.Stream<Key> distinctKeysStream()
int countKeys()
java.lang.Iterable<Value> distinctValues()
java.util.stream.Stream<Value> distinctValuesStream()
IMultiLookup.ChangeGranularity addPair(Key key, Value value)
If the addition would cause duplicates but the bucket type does not allow it (CollectionsFactory.MemoryType.SETS
),
the operation throws an IllegalStateException
.
java.lang.IllegalStateException
- if addition would cause duplication that is not permittedIMultiLookup.ChangeGranularity addPairOrNop(Key key, Value value)
If the addition would cause duplicates but the bucket type does not allow it (CollectionsFactory.MemoryType.SETS
),
the operation is silently ignored and IMultiLookup.ChangeGranularity.DUPLICATE
is returned.
IMultiLookup.ChangeGranularity.DUPLICATE
if addition would result in a duplicate and therefore ignoredIMultiLookup.ChangeGranularity removePair(Key key, Value value)
When attempting to remove a key-value pair with zero multiplicity from a non-delta bucket type
(CollectionsFactory.MemoryType.SETS
or CollectionsFactory.MemoryType.MULTISETS
}), an IllegalStateException
is thrown.
java.lang.IllegalStateException
- if removing non-existing element that is not permittedIMultiLookup.ChangeGranularity removePairOrNop(Key key, Value value)
When attempting to remove a key-value pair with zero multiplicity from a non-delta bucket type
(CollectionsFactory.MemoryType.SETS
or CollectionsFactory.MemoryType.MULTISETS
}),
the operation is silently ignored and IMultiLookup.ChangeGranularity.DUPLICATE
is returned.
java.lang.IllegalStateException
- if removing non-existing element that is not permittedIMultiLookup.ChangeGranularity addPairPositiveMultiplicity(Key key, Value value, int count)
PRE: count > 0
java.lang.IllegalStateException
- if addition would cause duplication that is not permittedvoid clear()
static <Key,Value> boolean equals(IMultiLookup<Key,Value> self, java.lang.Object obj)
static <Key,Value> int hashCode(IMultiLookup<Key,Value> memory)