Comments (3)
Does boost.algorithm have iterator hints for binary searches?
It does not; in fact, it doesn't haveupper_bound
at all.
However, that's an interesting idea. I'll think about it.
At the very least, you should be able to bisect the search range based on the hint.
from algorithm.
I've stumbled on a similar issue. I would like to do a binary search, but would like to add a hint as to where to start. However, if you think about it, you could to do the following:
auto new_begin = std::upper_bound(current_begin, current_end, test());
current_begin = new_begin;
So that when you do the next call to std::upper_bound
you'd ignore everything before the last search results. This is like stating the initial partition, which I think is the same thing, right?
from algorithm.
In my case, there is no hard guarantee that the desired element is strictly after the hint element. There is only a good reason to believe that the desired element is close to the hint element.
My mental model of this is closer to branch prediction. Fast if itβs right, not a disaster if itβs wrong.
from algorithm.
Related Issues (20)
- Automated formatting
- new implementation for string split
- boost::algorithm::trim_copy() does not remove \b character HOT 1
- fast variadic string-concat
- variadic min/max/minmax HOT 1
- Modular Boost C++ Libraries Request HOT 2
- Unexpected behavior when using algorithm::trim() to remove spaces HOT 3
- Several cxx algorithm headers are not self-sufficient/self-contained HOT 2
- Potential memory leak? HOT 5
- search example should be updated HOT 2
- Lack of bidimensional for_each HOT 3
- `replace_all` in VC++ 7.1 doesn't work from 1.55 onwards in some circumstances. HOT 1
- boost::algorithm::split_regex hangs and consumes CPU on dangling alternatives
- The apply_permutation algorithm requires C++11 HOT 4
- boost::algorithm::split_regex doesn't work with boost::u32regex.
- Doc request: indicate constexpr support for algorithms
- Feature Request: Any plan to add trim support for string_view?
- algorithm/string -- find_all_regex() gives a compiler error when the result container is vector<iterator_range<string::iterator>>
- Any plan for C++20 container related algorithms such as std::erase(_if)? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from algorithm.