Speeding up partition_point-based search

68 Views Asked by At

I've been recently doing a collection of lookups of indices that satisfy a given criterion as follows,

some_vector.partition_point(|x| x < &el)

In a loop that does millions of lookups

for el in elements {
    let iloc = some_vector.partition_point(|x| x < &el);
    some_other_vec.push(iloc);
}

This works rather fine, however, it seems there might be a faster way to perform the iloc lookups still. What am I missing here? The some_vector is ordered.

Note: using the partition point to find the amount of elements that satisfy a given criterion (= what is the bin that holds a given float el) - there might be a faster way to go about this alltogether I'm missing here?

0

There are 0 best solutions below