Module io.smallrye.common.search
Package io.smallrye.common.search
Class BinarySearch.ObjRange.InCollection.ByKey
java.lang.Object
io.smallrye.common.search.BinarySearch.ObjRange.InCollection.ByKey
- Enclosing class:
BinarySearch.ObjRange.InCollection
Search operations within a collection which operate on an extracted key using a custom midpoint function.
-
Method Summary
Modifier and TypeMethodDescription<T,C, K> T find(C collection, T from, T to, BinaryOperator<T> midpoint, BiFunction<C, T, K> keyExtractor, Predicate<K> test) Get the lowest index within the given range that satisfies the given test.<T,C, K, V>
Tfind(C collection, V searchVal, T from, T to, BinaryOperator<T> midpoint, BiFunction<C, T, K> keyExtractor, BiPredicate<V, K> keyTester) Get the lowest index within the given range that satisfies the given test for the search value.<T,C, K extends Comparable<? super K>>
TfindFirst(C collection, K searchKey, T from, T to, BinaryOperator<T> midpoint, BiFunction<C, T, K> keyExtractor) Get the lowest index within the given range whose key is equal to or greater than the search key, according to the natural order of the search space.<T,C, K> T findFirst(C collection, K searchKey, T from, T to, BinaryOperator<T> midpoint, BiFunction<C, T, K> keyExtractor, Comparator<? super K> cmp) Get the lowest index within the given range whose key is equal to or greater than the search key, according to the given comparator.
-
Method Details
-
find
public <T,C, T findK> (C collection, T from, T to, BinaryOperator<T> midpoint, BiFunction<C, T, K> keyExtractor, Predicate<K> test) Get the lowest index within the given range that satisfies the given test.- Type Parameters:
T- the index typeC- the collection typeK- the key type- Parameters:
collection- the collection object (must not benull)from- the low end of the range (inclusive)to- the high end of the range (exclusive)midpoint- the midpoint function (must not benull)keyExtractor- the key extraction function (must not benull)test- the test for the key (must not benull)- Returns:
- the lowest index within the range which satisfies the test, or
toif no values satisfy the test within the range
-
find
public <T,C, T findK, V> (C collection, V searchVal, T from, T to, BinaryOperator<T> midpoint, BiFunction<C, T, K> keyExtractor, BiPredicate<V, K> keyTester) Get the lowest index within the given range that satisfies the given test for the search value.- Type Parameters:
T- the index typeC- the collection typeK- the key typeV- the value type- Parameters:
collection- the collection object (must not benull)searchVal- the value to search forfrom- the low end of the range (inclusive)to- the high end of the range (exclusive)midpoint- the midpoint function (must not benull)keyExtractor- the key extraction function (must not benull)keyTester- the test for the key (must not benull)- Returns:
- the lowest index within the range which satisfies the test, or
toif no values satisfy the test within the range
-
findFirst
public <T,C, T findFirstK extends Comparable<? super K>> (C collection, K searchKey, T from, T to, BinaryOperator<T> midpoint, BiFunction<C, T, K> keyExtractor) Get the lowest index within the given range whose key is equal to or greater than the search key, according to the natural order of the search space.- Type Parameters:
T- the index typeC- the collection typeK- the key type- Parameters:
collection- the collection object (must not benull)searchKey- the key to search for (must not benull)from- the low end of the range (inclusive)to- the high end of the range (exclusive)midpoint- the midpoint function (must not benull)keyExtractor- the key extraction function (must not benull)- Returns:
- the lowest index within the range which satisfies the condition, or
toif no values satisfy the condition within the range
-
findFirst
public <T,C, T findFirstK> (C collection, K searchKey, T from, T to, BinaryOperator<T> midpoint, BiFunction<C, T, K> keyExtractor, Comparator<? super K> cmp) Get the lowest index within the given range whose key is equal to or greater than the search key, according to the given comparator.- Type Parameters:
T- the index typeC- the collection typeK- the key type- Parameters:
collection- the collection object (must not benull)searchKey- the key to search for (must not benull)from- the low end of the range (inclusive)to- the high end of the range (exclusive)midpoint- the midpoint function (must not benull)keyExtractor- the key extraction function (must not benull)cmp- the comparator (must not benull)- Returns:
- the lowest index within the range which satisfies the condition, or
toif no values satisfy the condition within the range
-