binarySearchIndex method

int binarySearchIndex(
  1. D id, [
  2. ComputeIDCompare<D>? compare
])

Returns the index of the entry with the given id, or -1 if not found.

Uses binary search and runs in O(log n). The list must be sorted by ID using compare.

Implementation

int binarySearchIndex(D id, [ComputeIDCompare<D>? compare]) {
  if (isEmpty) return -1;
  compare ??= _Comparer._defaultCompare;
  var v0 = first.$2;
  return _Comparer.binarySearchIndex<(D, V)>(
      this, (id, v0), (a, b) => compare!(a.$1, b.$1));
}