mirror of
https://github.com/boostorg/algorithm.git
synced 2025-07-03 07:46:49 +02:00
Merge a bunch of minor Boost.Algorithm changes to release
[SVN r86757]
This commit is contained in:
@ -19,11 +19,11 @@ The function `is_sorted(sequence)` determines whether or not a sequence is compl
|
|||||||
|
|
||||||
``
|
``
|
||||||
namespace boost { namespace algorithm {
|
namespace boost { namespace algorithm {
|
||||||
template <typename Iterator, typename Pred>
|
template <typename ForwardIterator, typename Pred>
|
||||||
bool is_sorted ( Iterator first, Iterator last, Pred p );
|
bool is_sorted ( ForwardIterator first, ForwardIterator last, Pred p );
|
||||||
|
|
||||||
template <typename Iterator>
|
template <typename ForwardIterator>
|
||||||
bool is_sorted ( Iterator first, Iterator last );
|
bool is_sorted ( ForwardIterator first, ForwardIterator last );
|
||||||
|
|
||||||
|
|
||||||
template <typename Range, typename Pred>
|
template <typename Range, typename Pred>
|
||||||
@ -34,7 +34,7 @@ namespace boost { namespace algorithm {
|
|||||||
}}
|
}}
|
||||||
``
|
``
|
||||||
|
|
||||||
Iterator requirements: The `is_sorted` functions will work on all kinds of iterators (except output iterators).
|
Iterator requirements: The `is_sorted` functions will work forward iterators or better.
|
||||||
|
|
||||||
[heading is_sorted_until]
|
[heading is_sorted_until]
|
||||||
|
|
||||||
@ -88,8 +88,8 @@ To test if a sequence is decreasing (each element no larger than the preceding o
|
|||||||
|
|
||||||
``
|
``
|
||||||
namespace boost { namespace algorithm {
|
namespace boost { namespace algorithm {
|
||||||
template <typename Iterator>
|
template <typename ForwardIterator>
|
||||||
bool is_decreasing ( Iterator first, Iterator last );
|
bool is_decreasing ( ForwardIterator first, ForwardIterator last );
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
bool is_decreasing ( const R &range );
|
bool is_decreasing ( const R &range );
|
||||||
@ -99,8 +99,8 @@ namespace boost { namespace algorithm {
|
|||||||
To test if a sequence is strictly increasing (each element larger than the preceding one):
|
To test if a sequence is strictly increasing (each element larger than the preceding one):
|
||||||
``
|
``
|
||||||
namespace boost { namespace algorithm {
|
namespace boost { namespace algorithm {
|
||||||
template <typename Iterator>
|
template <typename ForwardIterator>
|
||||||
bool is_strictly_increasing ( Iterator first, Iterator last );
|
bool is_strictly_increasing ( ForwardIterator first, ForwardIterator last );
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
bool is_strictly_increasing ( const R &range );
|
bool is_strictly_increasing ( const R &range );
|
||||||
@ -110,8 +110,8 @@ namespace boost { namespace algorithm {
|
|||||||
To test if a sequence is strictly decreasing (each element smaller than the preceding one):
|
To test if a sequence is strictly decreasing (each element smaller than the preceding one):
|
||||||
``
|
``
|
||||||
namespace boost { namespace algorithm {
|
namespace boost { namespace algorithm {
|
||||||
template <typename Iterator>
|
template <typename ForwardIterator>
|
||||||
bool is_strictly_decreasing ( Iterator first, Iterator last );
|
bool is_strictly_decreasing ( ForwardIterator first, ForwardIterator last );
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
bool is_strictly_decreasing ( const R &range );
|
bool is_strictly_decreasing ( const R &range );
|
||||||
|
@ -63,8 +63,8 @@ void iota ( Range &r, T value )
|
|||||||
template <typename OutputIterator, typename T>
|
template <typename OutputIterator, typename T>
|
||||||
OutputIterator iota_n ( OutputIterator out, T value, std::size_t n )
|
OutputIterator iota_n ( OutputIterator out, T value, std::size_t n )
|
||||||
{
|
{
|
||||||
while ( n-- > 0 )
|
for ( ; n > 0; --n, ++value )
|
||||||
*out++ = value++;
|
*out++ = value;
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include <boost/range/end.hpp>
|
#include <boost/range/end.hpp>
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/utility/enable_if.hpp>
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include <boost/tr1/tr1/tuple> // for tie
|
|
||||||
|
|
||||||
namespace boost { namespace algorithm {
|
namespace boost { namespace algorithm {
|
||||||
|
|
||||||
@ -121,7 +120,6 @@ bool is_permutation ( ForwardIterator1 first1, ForwardIterator1 last1,
|
|||||||
ForwardIterator2 first2, BinaryPredicate p )
|
ForwardIterator2 first2, BinaryPredicate p )
|
||||||
{
|
{
|
||||||
// Skip the common prefix (if any)
|
// Skip the common prefix (if any)
|
||||||
// std::tie (first1, first2) = std::mismatch (first1, last1, first2, p);
|
|
||||||
std::pair<ForwardIterator1, ForwardIterator2> eq = std::mismatch (first1, last1, first2, p);
|
std::pair<ForwardIterator1, ForwardIterator2> eq = std::mismatch (first1, last1, first2, p);
|
||||||
first1 = eq.first;
|
first1 = eq.first;
|
||||||
first2 = eq.second;
|
first2 = eq.second;
|
||||||
|
@ -20,7 +20,11 @@
|
|||||||
#include <boost/type_traits/remove_const.hpp>
|
#include <boost/type_traits/remove_const.hpp>
|
||||||
|
|
||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
|
#ifdef BOOST_NO_CXX11_HDR_UNORDERED_MAP
|
||||||
#include <boost/tr1/tr1/unordered_map>
|
#include <boost/tr1/tr1/unordered_map>
|
||||||
|
#else
|
||||||
|
#include <unordered_map>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <boost/algorithm/searching/detail/debugging.hpp>
|
#include <boost/algorithm/searching/detail/debugging.hpp>
|
||||||
|
|
||||||
@ -35,7 +39,11 @@ namespace boost { namespace algorithm { namespace detail {
|
|||||||
template<typename key_type, typename value_type>
|
template<typename key_type, typename value_type>
|
||||||
class skip_table<key_type, value_type, false> {
|
class skip_table<key_type, value_type, false> {
|
||||||
private:
|
private:
|
||||||
|
#ifdef BOOST_NO_CXX11_HDR_UNORDERED_MAP
|
||||||
typedef std::tr1::unordered_map<key_type, value_type> skip_map;
|
typedef std::tr1::unordered_map<key_type, value_type> skip_map;
|
||||||
|
#else
|
||||||
|
typedef std::unordered_map<key_type, value_type> skip_map;
|
||||||
|
#endif
|
||||||
const value_type k_default_value;
|
const value_type k_default_value;
|
||||||
skip_map skip_;
|
skip_map skip_;
|
||||||
|
|
||||||
|
@ -42,11 +42,11 @@ void test_ints () {
|
|||||||
std::vector<int> v;
|
std::vector<int> v;
|
||||||
std::list<int> l;
|
std::list<int> l;
|
||||||
|
|
||||||
v.clear (); v.reserve ( 10 );
|
v.clear (); v.resize ( 10 );
|
||||||
boost::algorithm::iota ( v.begin (), v.end (), 23 );
|
boost::algorithm::iota ( v.begin (), v.end (), 23 );
|
||||||
BOOST_CHECK ( test_iota_results ( v.begin (), v.end (), 23 ));
|
BOOST_CHECK ( test_iota_results ( v.begin (), v.end (), 23 ));
|
||||||
|
|
||||||
v.clear (); v.reserve ( 19 );
|
v.clear (); v.resize ( 19 );
|
||||||
boost::algorithm::iota ( v, 18 );
|
boost::algorithm::iota ( v, 18 );
|
||||||
BOOST_CHECK ( test_iota_results ( v, 18 ));
|
BOOST_CHECK ( test_iota_results ( v, 18 ));
|
||||||
|
|
||||||
@ -54,6 +54,10 @@ void test_ints () {
|
|||||||
boost::algorithm::iota_n ( std::back_inserter(v), 99, 20 );
|
boost::algorithm::iota_n ( std::back_inserter(v), 99, 20 );
|
||||||
BOOST_CHECK ( test_iota_results ( v, 99 ));
|
BOOST_CHECK ( test_iota_results ( v, 99 ));
|
||||||
|
|
||||||
|
v.clear ();
|
||||||
|
boost::algorithm::iota_n ( std::back_inserter(v), 99, 0 );
|
||||||
|
BOOST_CHECK ( v.size() == 0 );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
l.clear (); l.reserve ( 5 );
|
l.clear (); l.reserve ( 5 );
|
||||||
boost::algorithm::iota ( l.begin (), l.end (), 123 );
|
boost::algorithm::iota ( l.begin (), l.end (), 123 );
|
||||||
|
Reference in New Issue
Block a user