withConfig method

IMapOfSets<K, V> withConfig(
  1. ConfigMapOfSets config
)

Creates a new map-of-sets with the given config (ConfigMapOfSets).

To copy the config from another IMapOfSets:

mapOfSets = mapOfSets.withConfig(other.config);

To change the current config:

mapOfSets = mapOfSets.withConfig(mapOfSets.config.copyWith(isDeepEquals: isDeepEquals));

See also: withIdentityEquals and withDeepEquals.

Implementation

IMapOfSets<K, V> withConfig(ConfigMapOfSets config) {
  if (config == this.config)
    return this;
  else {
    // If the new config is not sorted it can use sorted or not sorted.
    // If the new config is sorted it can only use sorted.
    if ((!config.sortKeys || this.config.sortKeys) &&
        (!config.sortValues || this.config.sortValues))
      return IMapOfSets._unsafe(_mapOfSets, config);
    //
    // If the new config is sorted and the previous is not, it must sort.
    else
      return IMapOfSets.from(_mapOfSets, config: config);
  }
}