public interface IMultiLookupAbstract<Key,Value,Bucket extends MarkedMemory<Value>> extends IMultiLookup<Key,Value>
See specialized IMultiLookupAbstract.ToSetsAbstract, IMultiLookupAbstract.ToMultisetsAbstract for various bucket types.
Implemented as a Key->Object map with invariant:
Not intended as an API, but rather as a 'base class' for implementors. Realized as an interface with default implementations, instead of an abstract class, to ensure that implementors can easily choose a base class such as UnifiedMap to augment.
Implementor should inherit from a Map
| Modifier and Type | Interface and Description |
|---|---|
static interface |
IMultiLookupAbstract.ToMultisetsAbstract<Key,Value>
A multi-lookup whose buckets are multisets.
|
static interface |
IMultiLookupAbstract.ToSetsAbstract<Key,Value>
A multi-lookup whose buckets are sets.
|
IMultiLookup.ChangeGranularity| Modifier and Type | Method and Description |
|---|---|
default IMultiLookup.ChangeGranularity |
addPair(Key key,
Value value)
Adds key-value pair to the lookup structure, or fails if not possible.
|
default IMultiLookup.ChangeGranularity |
addPairInternal(Key key,
Value value,
boolean throwIfImpossible) |
default IMultiLookup.ChangeGranularity |
addPairOrNop(Key key,
Value value)
Adds key-value pair to the lookup structure.
|
default IMultiLookup.ChangeGranularity |
addPairPositiveMultiplicity(Key key,
Value value,
int count)
Updates multiplicity of key-value pair by a positive amount.
|
boolean |
addToBucket(Bucket bucket,
Value value,
boolean throwIfImpossible)
Increases the multiplicity of the value in the bucket.
|
Value |
asSingleton(Bucket bucket)
Checks whether the bucket is a singleton, i.e.
|
default int |
countKeys() |
Bucket |
createDeltaBucket(Value positive,
Value negative) |
Bucket |
createSingletonBucket(Value value) |
default java.lang.Iterable<Key> |
distinctKeys() |
default java.util.stream.Stream<Key> |
distinctKeysStream() |
default java.lang.Iterable<Value> |
distinctValues()
Iterates once over each distinct value.
|
default java.util.stream.Stream<Value> |
distinctValuesStream()
Iterates once over each distinct value.
|
boolean |
duplicatesAllowed() |
default void |
handleSingleton(Key key,
Bucket bucket) |
default IMemoryView<Value> |
lookup(Key key)
Returns a (read-only) bucket of values associated with the given key.
|
default IMemoryView<Value> |
lookupAndRemoveAll(Key key)
Returns a (read-only) bucket of values associated with the given key, while simultaneously removing them.
|
default boolean |
lookupExists(Key key)
Returns true if there are any values associated with the given key.
|
default 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.
|
java.lang.Object |
lowLevelGet(Key key)
Implementor shall bind to the low-level get() or equivalent of the underlying Key-to-Object map
|
java.lang.Object |
lowLevelGetUnsafe(java.lang.Object key)
Implementor shall bind to the low-level get() or equivalent of the underlying Key-to-Object map
|
java.lang.Iterable<Key> |
lowLevelKeySet()
Implementor shall bind to the low-level keySet() or equivalent of the underlying Key-to-Object map
|
void |
lowLevelPut(Key key,
java.lang.Object valueOrBucket)
Implementor shall bind to the low-level put() or equivalent of the underlying Key-to-Object map
|
java.lang.Object |
lowLevelPutIfAbsent(Key key,
Value value)
Implementor shall bind to the low-level putIfAbsent() or equivalent of the underlying Key-to-Object map
|
java.lang.Object |
lowLevelRemove(Key key)
Implementor shall bind to the low-level remove() or equivalent of the underlying Key-to-Object map
|
int |
lowLevelSize()
Implementor shall bind to the low-level size() or equivalent of the underlying Key-to-Object map
|
java.lang.Iterable<java.lang.Object> |
lowLevelValues()
Implementor shall bind to the low-level values() or equivalent of the underlying Key-to-Object map
|
boolean |
negativesAllowed() |
boolean |
removeFromBucket(Bucket bucket,
Value value,
boolean throwIfImpossible)
Decreases the multiplicity of the value in the bucket.
|
default IMultiLookup.ChangeGranularity |
removePair(Key key,
Value value)
Removes key-value pair from the lookup structure, or fails if not possible.
|
default IMultiLookup.ChangeGranularity |
removePairInternal(Key key,
Value value,
boolean throwIfImpossible) |
default IMultiLookup.ChangeGranularity |
removePairOrNop(Key key,
Value value)
Removes key-value pair from the lookup structure.
|
default IMemoryView<Value> |
yieldSingleton(Value value) |
clear, equals, hashCode, isEmpty, lookupOrEmpty, lookupUnsafeOrEmptyjava.lang.Object lowLevelGet(Key key)
java.lang.Object lowLevelGetUnsafe(java.lang.Object key)
java.lang.Object lowLevelRemove(Key key)
java.lang.Object lowLevelPutIfAbsent(Key key, Value value)
void lowLevelPut(Key key, java.lang.Object valueOrBucket)
java.lang.Iterable<java.lang.Object> lowLevelValues()
java.lang.Iterable<Key> lowLevelKeySet()
int lowLevelSize()
default boolean lookupExists(Key key)
IMultiLookuplookupExists in interface IMultiLookup<Key,Value>key - a key for which associated values are soughtdefault IMemoryView<Value> lookup(Key key)
IMultiLookuplookup in interface IMultiLookup<Key,Value>key - a key for which associated values are soughtdefault IMemoryView<Value> lookupAndRemoveAll(Key key)
IMultiLookuplookupAndRemoveAll in interface IMultiLookup<Key,Value>key - a key for which associated values are soughtdefault IMemoryView<Value> lookupUnsafe(java.lang.Object key)
IMultiLookuplookupUnsafe in interface IMultiLookup<Key,Value>key - a key for which associated values are sought (may or may not be of Key type)default IMultiLookup.ChangeGranularity addPair(Key key, Value value)
IMultiLookup If the addition would cause duplicates but the bucket type does not allow it (CollectionsFactory.MemoryType.SETS),
the operation throws an IllegalStateException.
addPair in interface IMultiLookup<Key,Value>default IMultiLookup.ChangeGranularity addPairOrNop(Key key, Value value)
IMultiLookup 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.
addPairOrNop in interface IMultiLookup<Key,Value>IMultiLookup.ChangeGranularity.DUPLICATE if addition would result in a duplicate and therefore ignoreddefault IMultiLookup.ChangeGranularity addPairInternal(Key key, Value value, boolean throwIfImpossible)
default IMultiLookup.ChangeGranularity addPairPositiveMultiplicity(Key key, Value value, int count)
IMultiLookupPRE: count > 0
addPairPositiveMultiplicity in interface IMultiLookup<Key,Value>default IMultiLookup.ChangeGranularity removePair(Key key, Value value)
IMultiLookup 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.
removePair in interface IMultiLookup<Key,Value>default IMultiLookup.ChangeGranularity removePairOrNop(Key key, Value value)
IMultiLookup 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.
removePairOrNop in interface IMultiLookup<Key,Value>default IMultiLookup.ChangeGranularity removePairInternal(Key key, Value value, boolean throwIfImpossible)
default java.lang.Iterable<Value> distinctValues()
IMultiLookupdistinctValues in interface IMultiLookup<Key,Value>default java.util.stream.Stream<Value> distinctValuesStream()
IMultiLookupdistinctValuesStream in interface IMultiLookup<Key,Value>default java.lang.Iterable<Key> distinctKeys()
distinctKeys in interface IMultiLookup<Key,Value>default java.util.stream.Stream<Key> distinctKeysStream()
distinctKeysStream in interface IMultiLookup<Key,Value>default int countKeys()
countKeys in interface IMultiLookup<Key,Value>boolean negativesAllowed()
boolean duplicatesAllowed()
boolean addToBucket(Bucket bucket, Value value, boolean throwIfImpossible)
java.lang.IllegalStateException - if disallowed duplication and throwIfImpossible is specifiedboolean removeFromBucket(Bucket bucket, Value value, boolean throwIfImpossible)
java.lang.IllegalStateException - if removing non-existing value (unless delta map) and throwIfImpossible is specifiedValue asSingleton(Bucket bucket)
Bucket createSingletonBucket(Value value)
default IMemoryView<Value> yieldSingleton(Value value)
Bucket createDeltaBucket(Value positive, Value negative)
positive - the previously existing value, or null if the delta is to contain a single negative tuplejava.lang.IllegalStateException - if deltas not supported