split method

Tuple<List<TValue>, List<TValue>> split(
  1. bool selector(
    1. TValue
    )
)

Splits the collection into two subsets.

Every element for which selector returns true is added to the Tuple.a list, otherwise it is added to the Tuple.b list.

Implementation

Tuple<List<TValue>, List<TValue>> split(bool Function(TValue) selector) {
  final collections = Tuple<List<TValue>, List<TValue>>([], []);
  forEach((element) {
    final collection = selector(element) ? collections.a : collections.b;
    collection.add(element);
  });
  return collections;
}