binarySearch method

Bloom<int> binarySearch(
  1. E element,
  2. int compare(
    1. E a,
    2. E b
    )
)

Returns the index of element in this sorted list via binary search.

  • element: The target element to search for.
  • compare: Custom comparison function returning negative, zero, or positive.

Requires:

  • The underlying list MUST be sorted according to compare.

Ensures:

  • Returns the zero-based index of element in O(log N), or negative value if not found.

Implementation

Bloom<int> binarySearch(E element, int Function(E a, E b) compare) =>
    computed((via) =>
        col.ListExtensions(via(_listBloom)).binarySearch(element, compare));