Suppose I have a sorted vector of numbers from 0 to 1. I want to know the indices, where values become larger than multiples of 0.1 (i.e. the [deciles](https://en.wikipedia.org/wiki/Decile). in the future maybe also percentiles).

A simple solution I have in mind is using std::lower\_bound:

```
std::vector<float> v;

/// something which fills the vector here

std::sort(v.begin(),v.end());

std::vector<float>::iterator i = v.begin();
for (float k = 0.1 ; k < 0.99 ; k+= 0.1) {
  i = std::lower_bound (v.begin(), v.end(), k);
  std::cout << "reached " << k << " at position " << (low-v.begin()) << std::endl;
  std::cout << "       going from " << *(low-1) << " to " << *low << std::endl;
  // for simplicity of the example, I don't check if low is the first item of the vector
}

```

Since the vector can be long, I was wondering if this can be made faster. A first optimisation is to not search the part of the vector below the previous decile:

```
i = std::lower_bound (i, v.end(), k);

```

But, assuming lower\_bound performs a binary search, this still scans the entire upper part of the vector for each decile over and over again and doesn't use the intermediate results from the previous binary search.

So ideally I would like to use a search function to which I can pass multiple search items, somehow like:

```
float searchvalues[9];
for (int k = 1; k <= 9 ; ++k) {
  searchvalues[k] = ((float)k)/10.;
}
int deciles[9] = FANCY_SEARCH(v.begin(),v.end(),searchvalues,9);

```

is there anything like this already around and existing in standard, boost, or other libraries?