| 
									
										
										
										
											2012-02-18 07:17:39 +00:00
										 |  |  | /* 
 | 
					
						
							|  |  |  |    Copyright (c) Marshall Clow 2011-2012. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    Distributed under the Boost Software License, Version 1.0. (See accompanying | 
					
						
							|  |  |  |    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /// \file  is_partitioned.hpp
 | 
					
						
							|  |  |  | /// \brief Tell if a sequence is partitioned
 | 
					
						
							|  |  |  | /// \author Marshall Clow
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef BOOST_ALGORITHM_IS_PARTITIONED_HPP
 | 
					
						
							|  |  |  | #define BOOST_ALGORITHM_IS_PARTITIONED_HPP
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-03 08:33:05 -08:00
										 |  |  | #include <boost/config.hpp>
 | 
					
						
							| 
									
										
										
										
											2012-02-18 07:17:39 +00:00
										 |  |  | #include <boost/range/begin.hpp>
 | 
					
						
							|  |  |  | #include <boost/range/end.hpp>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace boost { namespace algorithm { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /// \fn is_partitioned ( InputIterator first, InputIterator last, UnaryPredicate p )
 | 
					
						
							| 
									
										
										
										
											2017-02-22 01:25:38 +03:00
										 |  |  | /// \brief Tests to see if a sequence is partitioned according to a predicate. 
 | 
					
						
							|  |  |  | ///	   In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence.
 | 
					
						
							| 
									
										
										
										
											2012-02-18 07:17:39 +00:00
										 |  |  | /// 
 | 
					
						
							|  |  |  | /// \param first    The start of the input sequence
 | 
					
						
							|  |  |  | /// \param last     One past the end of the input sequence
 | 
					
						
							| 
									
										
										
										
											2012-12-28 17:51:56 +00:00
										 |  |  | /// \param p        The predicate to test the values with
 | 
					
						
							| 
									
										
										
										
											2012-02-18 07:17:39 +00:00
										 |  |  | /// \note           This function is part of the C++2011 standard library.
 | 
					
						
							|  |  |  | template <typename InputIterator, typename UnaryPredicate> | 
					
						
							| 
									
										
										
										
											2016-01-25 13:11:01 +03:00
										 |  |  | BOOST_CXX14_CONSTEXPR bool is_partitioned ( InputIterator first, InputIterator last, UnaryPredicate p ) | 
					
						
							| 
									
										
										
										
											2012-02-18 07:17:39 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-27 15:24:09 +00:00
										 |  |  | //  Run through the part that satisfy the predicate
 | 
					
						
							| 
									
										
										
										
											2012-02-18 07:17:39 +00:00
										 |  |  |     for ( ; first != last; ++first ) | 
					
						
							|  |  |  |         if ( !p (*first)) | 
					
						
							| 
									
										
										
										
											2012-05-27 15:24:09 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  | //  Now the part that does not satisfy the predicate
 | 
					
						
							| 
									
										
										
										
											2012-02-18 07:17:39 +00:00
										 |  |  |     for ( ; first != last; ++first ) | 
					
						
							|  |  |  |         if ( p (*first)) | 
					
						
							| 
									
										
										
										
											2012-05-27 15:24:09 +00:00
										 |  |  |             return false; | 
					
						
							| 
									
										
										
										
											2012-02-18 07:17:39 +00:00
										 |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /// \fn is_partitioned ( const Range &r, UnaryPredicate p )
 | 
					
						
							| 
									
										
										
										
											2017-02-22 01:25:38 +03:00
										 |  |  | /// \brief Tests to see if a sequence is partitioned according to a predicate. 
 | 
					
						
							|  |  |  | ///	   In other words, all the items in the sequence that satisfy the predicate are at the beginning of the sequence.
 | 
					
						
							| 
									
										
										
										
											2012-02-18 07:17:39 +00:00
										 |  |  | /// 
 | 
					
						
							|  |  |  | /// \param r        The input range
 | 
					
						
							| 
									
										
										
										
											2012-12-28 17:51:56 +00:00
										 |  |  | /// \param p        The predicate to test the values with
 | 
					
						
							| 
									
										
										
										
											2012-02-18 07:17:39 +00:00
										 |  |  | ///
 | 
					
						
							|  |  |  | template <typename Range, typename UnaryPredicate> | 
					
						
							| 
									
										
										
										
											2016-01-25 13:11:01 +03:00
										 |  |  | BOOST_CXX14_CONSTEXPR bool is_partitioned ( const Range &r, UnaryPredicate p ) | 
					
						
							| 
									
										
										
										
											2012-02-18 07:17:39 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     return boost::algorithm::is_partitioned (boost::begin(r), boost::end(r), p); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-27 15:24:09 +00:00
										 |  |  | #endif  // BOOST_ALGORITHM_IS_PARTITIONED_HPP
 |