beforeWhere method

Set<E> beforeWhere(
  1. bool test(
    1. E e
    ), {
  2. int skip = 0,
  3. bool includeInResult = false,
  4. bool reverse = false,
})

Return everything before a condition is met. 1, 2, 3.beforeWhere((e) => e == 3) returns 1, 2.

Optional skip skips that many occurrences: 1, 2, 3, 4.beforeWhere((e) => e.isEven, skip: 1) returns 1, 2, 3.

reverse counts occurrences from right to left: 1, 2, 3, 4.beforeWhere((e) => e.isEven, reverse: true) returns 1, 2, 3.

includeInResult includes the target element in the result unless all occurrences were skipped: 1, 2, 3, 4.beforeWhere((e) => e.isEven, includeInResult: true) returns 1, 2.

Implementation

Set<E> beforeWhere(
  bool Function(E e) test, {
  int skip = 0,
  bool includeInResult = false,
  bool reverse = false,
}) {
  return h
      .beforeWhereIterable(
        original: this,
        test: test,
        skip: skip,
        reverse: reverse,
        includeInResult: includeInResult,
      )
      .toSet();
}