proconlib

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub anqooqie/proconlib

:warning: std::upper_bound, but returns index (tools/upper_bound.hpp)

template <class ForwardIterator, class T>
typename ::std::iterator_traits<ForwardIterator>::difference_type upper_bound(ForwardIterator first, ForwardIterator last, T value);

It is identical to std::distance(first, std::upper_bound(first, last, value)).

Constraints

Time Complexity

License

Author

Code

#ifndef TOOLS_UPPER_BOUND_HPP
#define TOOLS_UPPER_BOUND_HPP

#include <iterator>
#include <algorithm>

namespace tools {

  template <class ForwardIterator, class T>
  auto upper_bound(ForwardIterator first, ForwardIterator last, const T& value) {
    return ::std::distance(first, ::std::upper_bound(first, last, value));
  }

  template <class ForwardIterator, class T, class Compare>
  auto upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp) {
    return ::std::distance(first, ::std::upper_bound(first, last, value, comp));
  }
}

#endif
#line 1 "tools/upper_bound.hpp"



#include <iterator>
#include <algorithm>

namespace tools {

  template <class ForwardIterator, class T>
  auto upper_bound(ForwardIterator first, ForwardIterator last, const T& value) {
    return ::std::distance(first, ::std::upper_bound(first, last, value));
  }

  template <class ForwardIterator, class T, class Compare>
  auto upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp) {
    return ::std::distance(first, ::std::upper_bound(first, last, value, comp));
  }
}


Back to top page