org.eclipse.viatra.query.runtime.matchers.util

## Interface IMultiLookupAbstract.ToMultisetsAbstract<Key,Value>

- All Superinterfaces:
    IMultiLookup<Key,Value>, IMultiLookupAbstract<Key,Value,MarkedMemory.MarkedMultiset<Value>>
  Enclosing interface:
    IMultiLookupAbstract<Key,Value,Bucket extends MarkedMemory<Value>>

      public static interface IMultiLookupAbstract.ToMultisetsAbstract<Key,Value>
      extends IMultiLookupAbstract<Key,Value,MarkedMemory.MarkedMultiset<Value>>

  A multi-lookup whose buckets are multisets.

  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-like class (primitive map possible) and bind the lowLevel* methods accordingly.

  No Implement:
    This interface is not intended to be implemented by clients.
  No Reference:
    This interface is not intended to be referenced by clients.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.eclipse.viatra.query.runtime.matchers.util.IMultiLookupAbstract

      `IMultiLookupAbstract.ToMultisetsAbstract<Key,Value>, IMultiLookupAbstract.ToSetsAbstract<Key,Value>`

    - ### Nested classes/interfaces inherited from interface org.eclipse.viatra.query.runtime.matchers.util.IMultiLookup

      `IMultiLookup.ChangeGranularity`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default boolean` | `addToBucket(MarkedMemory.MarkedMultiset<Value> bucket, Value value, boolean throwIfImpossible)` Increases the multiplicity of the value in the bucket.
    `default Value` | `asSingleton(MarkedMemory.MarkedMultiset<Value> bucket)` Checks whether the bucket is a singleton, i.e.
    `default MarkedMemory.MarkedMultiset<Value>` | `createDeltaBucket(Value positive, Value negative)`
    `MarkedMemory.MarkedMultiset<Value>` | `createMarkedMultiset()`
    `default MarkedMemory.MarkedMultiset<Value>` | `createSingletonBucket(Value value)`
    `default boolean` | `duplicatesAllowed()`
    `default boolean` | `negativesAllowed()`
    `default boolean` | `removeFromBucket(MarkedMemory.MarkedMultiset<Value> bucket, Value value, boolean throwIfImpossible)` Decreases the multiplicity of the value in the bucket.

    - ### Methods inherited from interface org.eclipse.viatra.query.runtime.matchers.util.IMultiLookupAbstract

      `addPair, addPairInternal, addPairOrNop, addPairPositiveMultiplicity, countKeys, distinctKeys, distinctKeysStream, distinctValues, distinctValuesStream, handleSingleton, lookup, lookupAndRemoveAll, lookupExists, lookupUnsafe, lowLevelGet, lowLevelGetUnsafe, lowLevelKeySet, lowLevelPut, lowLevelPutIfAbsent, lowLevelRemove, lowLevelSize, lowLevelValues, removePair, removePairInternal, removePairOrNop, yieldSingleton`

    - ### Methods inherited from interface org.eclipse.viatra.query.runtime.matchers.util.IMultiLookup

      `clear, equals, hashCode, isEmpty, lookupOrEmpty, lookupUnsafeOrEmpty`

- - ### Method Detail

    - #### createMarkedMultiset

          MarkedMemory.MarkedMultiset<Value> createMarkedMultiset()

      Returns:
        a fresh, empty marked multiset

    - #### negativesAllowed

          default boolean negativesAllowed()

      Specified by:
        `negativesAllowed` in interface `IMultiLookupAbstract<Key,Value,MarkedMemory.MarkedMultiset<Value>>`
      Returns:
        iff negative multiplicites are allowed

    - #### duplicatesAllowed

          default boolean duplicatesAllowed()

      Specified by:
        `duplicatesAllowed` in interface `IMultiLookupAbstract<Key,Value,MarkedMemory.MarkedMultiset<Value>>`
      Returns:
        iff larger-than-1 multiplicites are allowed

    - #### addToBucket

          default boolean addToBucket(MarkedMemory.MarkedMultiset<Value> bucket,
                                      Value value,
                                      boolean throwIfImpossible)

      Description copied from interface: `IMultiLookupAbstract`
      Increases the multiplicity of the value in the bucket.
      Specified by:
        `addToBucket` in interface `IMultiLookupAbstract<Key,Value,MarkedMemory.MarkedMultiset<Value>>`
      Returns:
        true iff non-duplicate

    - #### removeFromBucket

          default boolean removeFromBucket(MarkedMemory.MarkedMultiset<Value> bucket,
                                           Value value,
                                           boolean throwIfImpossible)

      Description copied from interface: `IMultiLookupAbstract`
      Decreases the multiplicity of the value in the bucket.
      Specified by:
        `removeFromBucket` in interface `IMultiLookupAbstract<Key,Value,MarkedMemory.MarkedMultiset<Value>>`
      Returns:
        false if removing duplicate value

    - #### asSingleton

          default Value asSingleton(MarkedMemory.MarkedMultiset<Value> bucket)

      Description copied from interface: `IMultiLookupAbstract`
      Checks whether the bucket is a singleton, i.e. it contains a single value with multiplicity +1
      Specified by:
        `asSingleton` in interface `IMultiLookupAbstract<Key,Value,MarkedMemory.MarkedMultiset<Value>>`
      Returns:
        the singleton value, or null if the bucket is not singleton

    - #### createSingletonBucket

          default MarkedMemory.MarkedMultiset<Value> createSingletonBucket(Value value)

      Specified by:
        `createSingletonBucket` in interface `IMultiLookupAbstract<Key,Value,MarkedMemory.MarkedMultiset<Value>>`
      Returns:
        a new bucket consisting of a sole value

    - #### createDeltaBucket

          default MarkedMemory.MarkedMultiset<Value> createDeltaBucket(Value positive,
                                                                       Value negative)

      Specified by:
        `createDeltaBucket` in interface `IMultiLookupAbstract<Key,Value,MarkedMemory.MarkedMultiset<Value>>`
      Parameters:
        `positive` - the previously existing value, or null if the delta is to contain a single negative tuple
      Returns:
        a new bucket consisting of a delta of two values