partitionPoint method

int partitionPoint(
  1. bool predicate(
    1. ByteArray
    )
)

Returns the index of the partition point according to the given predicate (the index of the first element of the second partition).

The slice is assumed to be partitioned according to the given predicate. This means that all elements for which the predicate returns true are at the start of the slice and all elements for which the predicate returns false are at the end.

Implementation

int partitionPoint(bool Function(ByteArray) predicate) {
  int left = 0;
  int right = length - 1;

  while (left <= right) {
    int mid = (left + right) ~/ 2;
    if (predicate(this[mid])) {
      left = mid + 1;
    } else {
      right = mid - 1;
    }
  }

  return left;
}