Module io.smallrye.common.search
Package io.smallrye.common.search
Class BinarySearch.LongRange.CustomMidpoint.InCollection.ByKey
java.lang.Object
io.smallrye.common.search.BinarySearch.LongRange.CustomMidpoint.InCollection.ByKey
- Enclosing class:
BinarySearch.LongRange.CustomMidpoint.InCollection
Search operations within a collection which operate on an extracted key using a custom midpoint function.
-
Method Summary
Modifier and TypeMethodDescription<C,K> long find(C collection, long from, long to, LongBinaryOperator midpoint, io.smallrye.common.function.ObjLongFunction<C, K> keyExtractor, Predicate<K> keyTester) Get the lowest index within the given range that satisfies the given test.<C,K, V> long find(C collection, V searchVal, long from, long to, LongBinaryOperator midpoint, io.smallrye.common.function.ObjLongFunction<C, K> keyExtractor, BiPredicate<V, K> keyTester) Get the lowest index within the given range that satisfies the given test for the search value.<C,K extends Comparable<? super K>>
longfindFirst(C collection, K searchKey, long from, long to, LongBinaryOperator midpoint, io.smallrye.common.function.ObjLongFunction<C, 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.<C,K> long findFirst(C collection, K searchKey, long from, long to, LongBinaryOperator midpoint, io.smallrye.common.function.ObjLongFunction<C, 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 <C,K> long find(C collection, long from, long to, LongBinaryOperator midpoint, io.smallrye.common.function.ObjLongFunction<C, K> keyExtractor, Predicate<K> keyTester) Get the lowest index within the given range that satisfies the given test.- Type Parameters:
C- 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)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
-
find
public <C,K, long findV> (C collection, V searchVal, long from, long to, LongBinaryOperator midpoint, io.smallrye.common.function.ObjLongFunction<C, 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:
C- 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 <C,K extends Comparable<? super K>> long findFirst(C collection, K searchKey, long from, long to, LongBinaryOperator midpoint, io.smallrye.common.function.ObjLongFunction<C, 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:
C- 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 <C,K> long findFirst(C collection, K searchKey, long from, long to, LongBinaryOperator midpoint, io.smallrye.common.function.ObjLongFunction<C, 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:
C- 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
-