mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-04 14:14:09 +00:00
add test: some algorithms
This commit is contained in:
parent
e2b207d3be
commit
830fc27394
8 changed files with 176 additions and 12 deletions
|
@ -1,6 +1,7 @@
|
|||
#ifndef SPROUT_ALGORITHM_EQUAL_RANGE_HPP
|
||||
#define SPROUT_ALGORITHM_EQUAL_RANGE_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/algorithm/lower_bound.hpp>
|
||||
#include <sprout/algorithm/upper_bound.hpp>
|
||||
|
@ -13,13 +14,15 @@ namespace sprout {
|
|||
// 25.4.3.3 equal_range
|
||||
//
|
||||
// recursion depth:
|
||||
// [first, last) is RandomAccessIterator -> O(log N)
|
||||
// otherwise -> O(N)
|
||||
// O(log N)
|
||||
//
|
||||
template<typename ForwardIterator, typename T, typename Compare>
|
||||
inline SPROUT_CONSTEXPR pair<ForwardIterator, ForwardIterator>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<ForwardIterator, ForwardIterator>
|
||||
equal_range(ForwardIterator first, ForwardIterator last, T const& value, Compare comp) {
|
||||
return {sprout::lower_bound(first, last, value, comp), sprout::upper_bound(first, last, value, comp)};
|
||||
return sprout::pair<ForwardIterator, ForwardIterator>{
|
||||
sprout::lower_bound(first, last, value, comp),
|
||||
sprout::upper_bound(first, last, value, comp)
|
||||
};
|
||||
}
|
||||
|
||||
template<typename ForwardIterator, typename T>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue