splitOnce method

(Slice<T>, Slice<T>)? splitOnce(
  1. bool pred(
    1. T
    )
)

Splits the slice on the first element that matches the specified predicate. If any matching elements are resent in the slice, returns the prefix before the match and suffix after. The matching element itself is not included. If no elements match, returns None.

Implementation

(Slice<T>, Slice<T>)? splitOnce(bool Function(T) pred) {
  var index = _start;
  while (index < _end) {
    if (pred(_list[index])) {
      return (Slice(_list, _start, index), Slice(_list, index + 1, _end));
    }
    index++;
  }
  return null;
}