withConfig method

ISet<T> withConfig(
  1. ConfigSet config
)

Creates a new set with the given config.

To copy the config from another ISet:

set = set.withConfig(other.config)

To change the current config:

set = set.withConfig(set.config.copyWith(isDeepEquals: isDeepEquals))

See also: withIdentityEquals and withDeepEquals.

Implementation

ISet<T> withConfig(ConfigSet 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.sort || this.config.sort)
      return ISetImpl._unsafe(_s, config: config);
    //
    // If the new config is sorted and the previous is not, it must sort.
    else
      return ISetImpl._unsafe(SFlat(_s, config: config), config: config);
  }
}