annotate DEPENDENCIES/generic/include/boost/algorithm/cxx11/is_partitioned.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 /*
Chris@16 2 Copyright (c) Marshall Clow 2011-2012.
Chris@16 3
Chris@16 4 Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 */
Chris@16 7
Chris@16 8 /// \file is_partitioned.hpp
Chris@16 9 /// \brief Tell if a sequence is partitioned
Chris@16 10 /// \author Marshall Clow
Chris@16 11
Chris@16 12 #ifndef BOOST_ALGORITHM_IS_PARTITIONED_HPP
Chris@16 13 #define BOOST_ALGORITHM_IS_PARTITIONED_HPP
Chris@16 14
Chris@16 15 #include <algorithm> // for std::is_partitioned, if available
Chris@16 16
Chris@16 17 #include <boost/range/begin.hpp>
Chris@16 18 #include <boost/range/end.hpp>
Chris@16 19
Chris@16 20 namespace boost { namespace algorithm {
Chris@16 21
Chris@16 22 /// \fn is_partitioned ( InputIterator first, InputIterator last, UnaryPredicate p )
Chris@16 23 /// \brief Tests to see if a sequence is partitioned according to a predicate
Chris@16 24 ///
Chris@16 25 /// \param first The start of the input sequence
Chris@16 26 /// \param last One past the end of the input sequence
Chris@16 27 /// \param p The predicate to test the values with
Chris@16 28 /// \note This function is part of the C++2011 standard library.
Chris@16 29 /// We will use the standard one if it is available,
Chris@16 30 /// otherwise we have our own implementation.
Chris@16 31 template <typename InputIterator, typename UnaryPredicate>
Chris@16 32 bool is_partitioned ( InputIterator first, InputIterator last, UnaryPredicate p )
Chris@16 33 {
Chris@16 34 // Run through the part that satisfy the predicate
Chris@16 35 for ( ; first != last; ++first )
Chris@16 36 if ( !p (*first))
Chris@16 37 break;
Chris@16 38 // Now the part that does not satisfy the predicate
Chris@16 39 for ( ; first != last; ++first )
Chris@16 40 if ( p (*first))
Chris@16 41 return false;
Chris@16 42 return true;
Chris@16 43 }
Chris@16 44
Chris@16 45 /// \fn is_partitioned ( const Range &r, UnaryPredicate p )
Chris@16 46 /// \brief Generates an increasing sequence of values, and stores them in the input Range.
Chris@16 47 ///
Chris@16 48 /// \param r The input range
Chris@16 49 /// \param p The predicate to test the values with
Chris@16 50 ///
Chris@16 51 template <typename Range, typename UnaryPredicate>
Chris@16 52 bool is_partitioned ( const Range &r, UnaryPredicate p )
Chris@16 53 {
Chris@16 54 return boost::algorithm::is_partitioned (boost::begin(r), boost::end(r), p);
Chris@16 55 }
Chris@16 56
Chris@16 57
Chris@16 58 }}
Chris@16 59
Chris@16 60 #endif // BOOST_ALGORITHM_IS_PARTITIONED_HPP