commons-collections icon indicating copy to clipboard operation
commons-collections copied to clipboard

Sorted List binarySearch functions

Open kvr000 opened this issue 1 year ago • 1 comments

Based on PR for commons-lang3 https://github.com/apache/commons-lang/pull/1270

There is Collections.binarySearch() in Java core. However, it searches for exact element which is often not usable, as the elements are typically sorted by particular field.

These methods introduce binarySearch() on (sorted) List, with ability to provide sorting key extraction function and key comparator.

The rest of semantics, behavior, parameters and return values remain consistent with Collections.binarySearch() from Java core.

kvr000 avatar Sep 13 '24 04:09 kvr000

@kvr000 Please only provide only one binarySearch() API in this PR, like ArrayUtils in Commons Lang, no First/Last API.

garydgregory avatar Sep 13 '24 14:09 garydgregory