toSet method

  1. @override
Set<T> toSet({
  1. int compare(
    1. T a,
    2. T b
    )?,
})
override

Returns a Set with all items from the ISet.

If you provide a compare function, the resulting set will be sorted with it.

Implementation

@override
Set<T> toSet({int Function(T a, T b)? compare}) {
  if (config.sort && compare == null) {
    List<T> orderedList = (flush._s as SFlat<T>).toList(growable: false);
    return LinkedHashSet.of(orderedList);
  } else {
    if (compare != null) {
      var orderedList = toList(growable: false, compare: compare);
      return LinkedHashSet.of(orderedList);
    } else {
      return LinkedHashSet.of(_s);
    }
  }
}