summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2019-04-16 23:53:28 +0000
committerSam McCall <sam.mccall@gmail.com>2019-04-16 23:53:28 +0000
commit6b44291b5c4d5fe907b001f574485c8b38c5f191 (patch)
tree3d9fb61da236e8ac3d856a8d232c53b5ca01dbc4 /llvm/lib/Transforms
parentd5bc5ca3e4f6548654dd2fb8684d336146e85907 (diff)
downloadbcm5719-llvm-6b44291b5c4d5fe907b001f574485c8b38c5f191.tar.gz
bcm5719-llvm-6b44291b5c4d5fe907b001f574485c8b38c5f191.zip
[ADT] llvm::bsearch, binary search for mere mortals
Summary: Add to STLExtras a binary search function with a simple mental model: You provide a range and a predicate which is true above a certain point. bsearch() tells you that point. Overloads are provided for integers, iterators, and containers. This is more suitable than std:: alternatives in many cases: - std::binary_search only indicates presence/absence - upper_bound/lower_bound give you the opportunity to pick the wrong one - all of the options have confusing names and definitions when your predicate doesn't have simple "less than" semantics - all of the options require iterators - we plumb around a useless `value` parameter that should be a lambda capture The API is inspired by Go's standard library, but we add an extra parameter as well as some overloads and templates to show how clever C++ is. Reviewers: ilya-biryukov, gribozavr Subscribers: dexonsmith, kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60779 llvm-svn: 358540
Diffstat (limited to 'llvm/lib/Transforms')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud