2 Copyright (c) Alexander Zaitsev <zamazan4ik@gmail.by>, 2017.
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 /// \file is_partitioned_until.hpp
9 /// \brief Tell if a sequence is partitioned
10 /// \author Alexander Zaitsev
12 #ifndef BOOST_ALGORITHM_IS_PARTITIONED_UNTIL_HPP
13 #define BOOST_ALGORITHM_IS_PARTITIONED_UNTIL_HPP
15 #include <boost/config.hpp>
16 #include <boost/range/begin.hpp>
17 #include <boost/range/end.hpp>
19 namespace boost { namespace algorithm {
21 /// \fn is_partitioned_until ( InputIterator first, InputIterator last, UnaryPredicate p )
22 /// \brief Tests to see if a sequence is partitioned according to a predicate.
23 /// In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence.
25 /// \param first The start of the input sequence
26 /// \param last One past the end of the input sequence
27 /// \param p The predicate to test the values with
29 /// \note Returns the first iterator 'it' in the sequence [first, last) for which is_partitioned(first, it, p) is false.
30 /// Returns last if the entire sequence is partitioned.
32 template <typename InputIterator, typename UnaryPredicate>
33 InputIterator is_partitioned_until ( InputIterator first, InputIterator last, UnaryPredicate p )
35 // Run through the part that satisfy the predicate
36 for ( ; first != last; ++first )
39 // Now the part that does not satisfy the predicate
40 for ( ; first != last; ++first )
46 /// \fn is_partitioned_until ( const Range &r, UnaryPredicate p )
47 /// \brief Tests to see if a sequence is partitioned according to a predicate.
48 /// In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence.
50 /// \param r The input range
51 /// \param p The predicate to test the values with
53 /// \note Returns the first iterator 'it' in the sequence [first, last) for which is_partitioned(first, it, p) is false.
54 /// Returns last if the entire sequence is partitioned.
56 template <typename Range, typename UnaryPredicate>
57 typename boost::range_iterator<const Range>::type is_partitioned_until ( const Range &r, UnaryPredicate p )
59 return boost::algorithm::is_partitioned_until (boost::begin(r), boost::end(r), p);
64 #endif // BOOST_ALGORITHM_IS_PARTITIONED_UNTIL_HPP