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/range/begin.hpp>
16 #include <boost/range/end.hpp>
18 namespace boost { namespace algorithm {
20 /// \fn is_partitioned_until ( InputIterator first, InputIterator last, UnaryPredicate p )
21 /// \brief Tests to see if a sequence is partitioned according to a predicate.
22 /// In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence.
24 /// \param first The start of the input sequence
25 /// \param last One past the end of the input sequence
26 /// \param p The predicate to test the values with
28 /// \note Returns the first iterator 'it' in the sequence [first, last) for which is_partitioned(first, it, p) is false.
29 /// Returns last if the entire sequence is partitioned.
31 template <typename InputIterator, typename UnaryPredicate>
32 InputIterator is_partitioned_until ( InputIterator first, InputIterator last, UnaryPredicate p )
34 // Run through the part that satisfy the predicate
35 for ( ; first != last; ++first )
38 // Now the part that does not satisfy the predicate
39 for ( ; first != last; ++first )
45 /// \fn is_partitioned_until ( const Range &r, UnaryPredicate p )
46 /// \brief Tests to see if a sequence is partitioned according to a predicate.
47 /// In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence.
49 /// \param r The input range
50 /// \param p The predicate to test the values with
52 /// \note Returns the first iterator 'it' in the sequence [first, last) for which is_partitioned(first, it, p) is false.
53 /// Returns last if the entire sequence is partitioned.
55 template <typename Range, typename UnaryPredicate>
56 typename boost::range_iterator<const Range>::type is_partitioned_until ( const Range &r, UnaryPredicate p )
58 return boost::algorithm::is_partitioned_until (boost::begin(r), boost::end(r), p);
63 #endif // BOOST_ALGORITHM_IS_PARTITIONED_UNTIL_HPP