IMapOfSets<K, V> class

An immutable, unordered, map of sets.

Inheritance
Annotations
  • @immutable

Constructors

IMapOfSets([Map<K, Iterable<V>>? mapOfSets])
factory
IMapOfSets.from(IMap<K, ISet<V>> imap, {ConfigMapOfSets? config})
Creates an IMapOfSets from an IMap of sets. The resulting map and its sets will be sorted according to config, or, if not provided, according to the default configuration for ConfigMapOfSets.
IMapOfSets.withConfig(Map<K, Iterable<V>>? mapOfSets, ConfigMapOfSets config)
Create an IMapOfSets from a map of sets and a ConfigMapOfSets.
factory

Properties

config ConfigMapOfSets
The map-of-sets configuration.
final
configMap ConfigMap
The internal IMap configuration.
no setter
configSet ConfigSet
The internal ISet configuration.
no setter
entries Iterable<MapEntry<K, ISet<V>>>
Return iterable of entries, where each entry is the key:set pair.
no setter
entriesAsSet ISet<MapEntry<K, ISet<V>>>
Returns an ISet of the MapEntry's.
no setter
flush IMapOfSets<K, V>
Flushes this collection, if necessary. Chainable method.
no setteroverride
hashCode int
The hash code for this object.
no setteroverride
isDeepEquals bool
See also: ConfigMapOfSets
no setter
isEmpty bool
Returns true if there are no elements in this collection.
no setteroverride
isFlushed bool
Whether this collection is already flushed or not.
no setteroverride
isIdentityEquals bool
See also: ConfigMapOfSets
no setter
isNotEmpty bool
Returns true if there is at least one element in this collection.
no setteroverride
keys Iterable<K>
Returns an Iterable of the map keys.
no setter
keysAsList IList<K>
Return all keys.
no setter
keysAsSet ISet<K>
Returns an ISet of the keys.
no setter
lengthOfKeys int
The number of keys.
no setter
lengthOfNonRepeatingValues int
The sum of the number of unique values of all sets.
no setter
lengthOfValues int
The sum of the number of values of all sets.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sets Iterable<ISet<V>>
Returns an Iterable of the map values.
no setter
setsAsList IList<ISet<V>>
Returns a list of the internal sets.
no setter
setsAsSet ISet<ISet<V>>
Returns an ISet of the internal sets.
no setter
unlock Map<K, Set<V>>
Unlocks the map, returning a regular (mutable, ordered) Map<K, Set<V> of type LinkedHashMap. This map is "safe", in the sense that is independent from the original IMap.
no setter
values Iterable<V>
Return all values of all sets, in order, including duplicates.
no setter
valuesAsSet ISet<V>
Return all values of all sets, removing duplicates.
no setter

Methods

add(K key, V value) IMapOfSets<K, V>
Find the key/set entry, and add the value to the set. If the key doesn't exist, will first create it with an empty set, and then add the value to it. If the value already exists in the set, nothing happens.
addEntries(Iterable<MapEntry<K, Set<V>>> entries) IMapOfSets<K, V>
Adds all set values to this map.
addIMap(IMap<K, Set<V>> map) IMapOfSets<K, V>
Adds all set values to this map.
addMap(Map<K, Set<V>> map) IMapOfSets<K, V>
Adds all set values to this map.
addValues(K key, Iterable<V> values) IMapOfSets<K, V>
Find the key/set entry, and add all the values to the set. If the key doesn't exist, will first create it with an empty set, and then add the values to it.
addValuesToKeys(Iterable<K> keys, Iterable<V> values) IMapOfSets<K, V>
Add all values to each set of all given keys. If the key doesn't exist, it will first create it with an empty set, and then add the values to it.
allEntriesWithValue(V value) Set<MapEntry<K, ISet<V>>>
Return any key:set entry where the value exists in the set. If that entry doesn't exist, return null.
allKeysWithValue(V value) Set<K>
Returns a Set of the keys which contain value.
asIMap() IMap<K, ISet<V>>
Returns this IMapOfSets<K, V> as an IMap<K, ISet<V>>.
cast<RK, RV>() IMapOfSets<RK, RV>
Provides a view of this map of sets as having RK keys and RV instances, if necessary.
clear() IMapOfSets<K, V>
If removeEmptySets is true, returns an empty map of sets with the same configuration. However, if removeEmptySets is false, keep the keys, but make their sets empty.
clearSet(K key) IMapOfSets<K, V>
When removeEmptySets is true, the given key and its corresponding set will be removed. This is the same as calling removeSet.
contains(K key, V value) bool
Return true if the given key entry exists, and its set contains the given value.
containsKey(K? key) bool
Return true if the given key exists.
containsValue(V value) bool
Return true if the value exists in any of the sets.
entry(K key) MapEntry<K, ISet<V>?>
Return the MapEntry for the given key. For key/value pairs that don't exist, it will return MapEntry(key, null);.
entryOrNull(K key) MapEntry<K, ISet<V>>?
Return the MapEntry for the given key. For key/value pairs that don't exist, it will return null.
equalItems(covariant Iterable<MapEntry> other) bool
Will return true only if the ISet has the same number of items as the iterable, and the ISet items are equal to the iterable items, in whatever order. This may be slow for very large sets, since it compares each item, one by one.
override
equalItemsAndConfig(IMapOfSets other) bool
Will return true only if the list items are equal, and the map of sets configurations (ConfigMapOfSets) are equal. This may be slow for very large maps, since it compares each item, one by one.
override
equalItemsToIMap<RK, RV>(IMap<RK, ISet<RV>> other) bool
Will return true only if the two maps have the same number of entries, and if the entries of the two maps are pairwise equal on both key and value.
equalItemsToIMapOfSets(IMapOfSets other) bool
Will return true only if the two maps have the same number of entries, and if the entries of the two maps are pairwise equal on both key and value.
firstValueWhere(bool test(V), {V orElse()?}) → V
Iterates through all values of all sets, and returns the first value it finds that satisfies test.
firstValueWhereOrNull(bool test(V), {V? orElse()?}) → V?
Iterates through all values of all sets, and returns the first value it finds that satisfies test.
flatten() Iterable<MapEntry<K, V>>
Return a flattened iterable of <K, V> entries (including eventual duplicates), where each entry is a key:value pair. For example, if the map is {1: {a, b}, 2: {x, y}}, it will return (1:a), (1:b), (2:x), (2:y).
forEach(void f(K key, ISet<V> set)) → void
Applies the function f to each element.
get(K key) ISet<V>
Return the set for the given key. If the key doesn't exist, return an empty set (never return null).
getEntryWithValue(V value) MapEntry<K, ISet<V>>?
Return any key:set entry where the value exists in the set. If that entry doesn't exist, return null.
getKeyWithValue(V value) → K?
Return any key entry where the value exists in its set. If it doesn't find the value, return null.
getOrNull(K key) ISet<V>?
Return the set for the given key. If the key doesn't exist, return null.
invertKeysAndValues([ConfigMapOfSets? config]) IMapOfSets<V, K>
Return a map where the keys are the values, and the values are the keys. Keys of empty sets will be removed. You can pass a new config for the map.
invertKeysAndValuesKeepingNullKeys([ConfigMapOfSets? config]) IMapOfSets<V?, K>
Return a map where the keys are the values, and the values are the keys. Empty sets will become the key null. You can pass a new config for the map.
isEmptyForKey(K key) bool
Return true if the value set is empty or null, for the given key. Return false if there are 1 or more values, for the given key.
isNotEmptyForKey(K key) bool
Return true if there are 1 or more values, for the given key. Return false if the value set is empty or null, for the given key.
keyList({ConfigList? config}) IList<K>
Returns an IList of the map keys. Optionally, you may provide a config for the list.
map<RK, RV>(MapEntry<RK, ISet<RV>> mapper(K key, ISet<V> set), {ConfigMapOfSets? config}) IMapOfSets<RK, RV>
Returns a new map where all entries of this map are transformed by the given mapper function. You may provide a config, otherwise it will be the same as the original map.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(K key, V value) IMapOfSets<K, V>
Find the key/set entry, and remove the value from the set. If the key doesn't exist, don't do anything. If the set becomes empty and removeEmptySets is true, the key will be removed entirely. Otherwise, the key will be kept and the set will be empty (not null).
removeSet(K key) IMapOfSets<K, V>
Remove the given key, if it exists, and its corresponding set. If the key doesn't exist, don't do anything.
removeValues(List<V> values, {Output<int>? numberOfRemovedValues}) IMapOfSets<K, V>
Remove all given values from all sets. If a set becomes empty and removeEmptySets is true, its key will be removed entirely. Otherwise, its key will be kept and the set will be empty (not null). If you want, you can pass numberOfRemovedValues to get the number of removed values.
removeValuesFromKeyWhere(K key, bool test(V value)) IMapOfSets<K, V>
Remove, from the given key set, all values that satisfy the given test. If the set becomes empty, the key will be removed entirely.
removeValuesWhere(bool test(K key, V value), {Output<int>? numberOfRemovedValues}) IMapOfSets<K, V>
Remove, from all sets, all given values that satisfy the given test. If a set becomes empty, its key will be removed entirely. If you want, you can pass numberOfRemovedValues to get the number of removed values.
removeWhere(bool predicate(K key, ISet<V> set)) IMapOfSets<K, V>
Removes all entries (key:set pair) of this map that satisfy the given predicate.
replaceSet(K key, ISet<V> set) IMapOfSets<K, V>
  • When removeEmptySets is true: If the given set is not empty, add the key/set entry. If the key already exists, replace it with the new set entirely. If the given set is empty, the key/set entry will be removed (same as calling removeSet).

  • When removeEmptySets is false: Add the key/set entry. If the key already exists, replace it with the new set entirely.

  • same(IMapOfSets<K, V> other) bool
    Will return true only if the maps internals are the same instances (comparing by identity). This will be fast even for very large maps, since it doesn't compare each entry.
    override
    toggle(K key, V value, {bool? state}) IMapOfSets<K, V>
    Removes the value from the set of the corresponding key, if it exists in the set. Otherwise, adds it to the set. If the key doesn't exist, it will be created and then have the new value added to the new, corresponding set.
    toString([bool? prettyPrint]) String
    Returns a string representation of (some of) the elements of this.
    override
    update(K key, ISet<V> update(ISet<V> set), {ISet<V> ifAbsent()?, Output<ISet<V>>? previousSet}) IMapOfSets<K, V>
    Updates the set for the provided key.
    updateAll(ISet<V> update(K key, ISet<V> set)) IMapOfSets<K, V>
    Updates all sets.
    valueList({ConfigList? config}) IList<V>
    Returns an IList of the all values in all sets.
    withConfig(ConfigMapOfSets config) IMapOfSets<K, V>
    Creates a new map-of-sets with the given config (ConfigMapOfSets).

    Operators

    operator ==(Object other) bool
  • If isDeepEquals configuration is true: Will return true only if the map entries are equal (not necessarily in the same order), and the map configurations are equal. This may be slow for very large maps, since it compares each entry, one by one.

  • If isDeepEquals configuration is false: Will return true only if the maps internals are the same instances (comparing by identity). This will be fast even for very large maps, since it doesn't compare each entry.

  • override
    operator [](K key) ISet<V>?
    Return the set for the given key. If the key doesn't exist, return null.

    Static Properties

    defaultConfig ConfigMapOfSets
    Global configuration that specifies if, by default, the IMapOfSets use equality or identity for their operator ==.
    getter/setter pair

    Static Methods

    empty<K, V>([ConfigMapOfSets? config]) IMapOfSets<K, V>
    Returns an empty IMapOfSets, with the given configuration. If a configuration is not provided, it will use the default configuration.
    fromIterable<K, V, I>(Iterable<I> iterable, {K keyMapper(I)?, V valueMapper(I)?, bool ignore(I)?, ConfigMapOfSets? config}) IMapOfSets<K, V>
    Creates a map of sets instance in which the keys and values are computed from the iterable.
    orNull<K, V>(Map<K, Iterable<V>>? map, [ConfigMapOfSets? config]) IMapOfSets<K, V>?
    If mapOfSets is null, return null.