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.
|
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)
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.lang.Iterable<Value> |
distinctValues()
Iterates once over each distinct value.
|
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> |
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
|
void |
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)
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.
|
default IMemoryView<Value> |
yieldSingleton(Value value) |
clear, equals, hashCode, isEmpty, lookupOrEmpty, lookupUnsafeOrEmpty
java.lang.Object lowLevelGet(Key key)
java.lang.Object lowLevelGetUnsafe(java.lang.Object key)
void 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 IMemoryView<Value> lookup(Key key)
IMultiLookup
lookup
in interface IMultiLookup<Key,Value>
key
- a key for which associated values are soughtdefault IMemoryView<Value> lookupUnsafe(java.lang.Object key)
IMultiLookup
lookupUnsafe
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
addPair
in interface IMultiLookup<Key,Value>
default IMultiLookup.ChangeGranularity addPairPositiveMultiplicity(Key key, Value value, int count)
IMultiLookup
PRE: count > 0
addPairPositiveMultiplicity
in interface IMultiLookup<Key,Value>
default IMultiLookup.ChangeGranularity removePair(Key key, Value value)
IMultiLookup
removePair
in interface IMultiLookup<Key,Value>
default java.lang.Iterable<Value> distinctValues()
IMultiLookup
distinctValues
in interface IMultiLookup<Key,Value>
default java.lang.Iterable<Key> distinctKeys()
distinctKeys
in interface IMultiLookup<Key,Value>
default int countKeys()
countKeys
in interface IMultiLookup<Key,Value>
boolean negativesAllowed()
boolean addToBucket(Bucket bucket, Value value)
java.lang.IllegalStateException
- if disallowed duplicationboolean removeFromBucket(Bucket bucket, Value value)
java.lang.IllegalStateException
- if removing non-existing value (unless delta map)Value 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