ListSet<T>.of constructor
Create a ListSet from the items
iterable.
If sort
is true, it will be sorted with compare
, if provided,
or with compareObject if not provided. If sort
is false,
compare
will be ignored.
Implementation
ListSet.of(
Iterable<T> items, {
bool sort = false,
int Function(T a, T b)? compare,
}) : assert(compare == null || sort == true) {
_set = HashSet();
_list = List.of(items.where((item) => _set.add(item)), growable: false);
if (sort) _list.sort(compare ?? compareObject);
}