Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:23

0001 /* 
0002    Copyright (c) Marshall Clow 2008-2012.
0003 
0004    Distributed under the Boost Software License, Version 1.0. (See accompanying
0005    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 */
0007 
0008 /// \file  none_of.hpp
0009 /// \brief Test ranges to see if no elements match a value or predicate.
0010 /// \author Marshall Clow
0011 
0012 #ifndef BOOST_ALGORITHM_NONE_OF_HPP
0013 #define BOOST_ALGORITHM_NONE_OF_HPP
0014 
0015 #include <boost/config.hpp>
0016 #include <boost/range/begin.hpp>
0017 #include <boost/range/end.hpp>
0018 
0019 namespace boost { namespace algorithm {
0020 
0021 /// \fn none_of ( InputIterator first, InputIterator last, Predicate p )
0022 /// \return true if none of the elements in [first, last) satisfy the predicate 'p'
0023 /// \note returns true on an empty range
0024 /// 
0025 /// \param first The start of the input sequence
0026 /// \param last  One past the end of the input sequence
0027 /// \param p     A predicate for testing the elements of the sequence
0028 ///
0029 template<typename InputIterator, typename Predicate> 
0030 BOOST_CXX14_CONSTEXPR bool none_of ( InputIterator first, InputIterator last, Predicate p )
0031 {
0032     for ( ; first != last; ++first )
0033         if ( p(*first)) 
0034             return false;
0035     return true;
0036 } 
0037 
0038 /// \fn none_of ( const Range &r, Predicate p )
0039 /// \return true if none of the elements in the range satisfy the predicate 'p'
0040 /// \note returns true on an empty range
0041 /// 
0042 /// \param r     The input range
0043 /// \param p     A predicate for testing the elements of the range
0044 ///
0045 template<typename Range, typename Predicate> 
0046 BOOST_CXX14_CONSTEXPR bool none_of ( const Range &r, Predicate p )
0047 {
0048     return boost::algorithm::none_of (boost::begin (r), boost::end (r), p );
0049 } 
0050 
0051 /// \fn none_of_equal ( InputIterator first, InputIterator last, const V &val )
0052 /// \return true if none of the elements in [first, last) are equal to 'val'
0053 /// \note returns true on an empty range
0054 /// 
0055 /// \param first The start of the input sequence
0056 /// \param last  One past the end of the input sequence
0057 /// \param val   A value to compare against
0058 ///
0059 template<typename InputIterator, typename V> 
0060 BOOST_CXX14_CONSTEXPR bool none_of_equal ( InputIterator first, InputIterator last, const V &val ) 
0061 {
0062     for ( ; first != last; ++first )
0063         if ( val == *first )
0064             return false;
0065     return true; 
0066 } 
0067 
0068 /// \fn none_of_equal ( const Range &r, const V &val )
0069 /// \return true if none of the elements in the range are equal to 'val'
0070 /// \note returns true on an empty range
0071 /// 
0072 /// \param r     The input range
0073 /// \param val   A value to compare against
0074 ///
0075 template<typename Range, typename V> 
0076 BOOST_CXX14_CONSTEXPR bool none_of_equal ( const Range &r, const V & val ) 
0077 {
0078     return boost::algorithm::none_of_equal (boost::begin (r), boost::end (r), val);
0079 } 
0080 
0081 }} // namespace boost and algorithm
0082 
0083 #endif // BOOST_ALGORITHM_NONE_OF_HPP