BVB Source Codes

mars Show any_of.hpp Source code

Return Download mars: download any_of.hpp Source code - Download mars Source code - Type:.hpp
  1. /*
  2.    Copyright (c) Marshall Clow 2008-2012.
  3.  
  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)
  6.  
  7.     For more information, see http://www.boost.org
  8. */
  9.  
  10. /// \file
  11. /// \brief Test ranges to see if any elements match a value or predicate.
  12. /// \author Marshall Clow
  13.  
  14. #ifndef BOOST_ALGORITHM_ANY_OF_HPP
  15. #define BOOST_ALGORITHM_ANY_OF_HPP
  16.  
  17. #include <algorithm>    // for std::any_of, if available
  18. #include <boost/range/begin.hpp>
  19. #include <boost/range/end.hpp>
  20.  
  21. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost {  namespace algorithm {
  22.  
  23. //  Use the C++11 versions of any_of if it is available
  24. #if __cplusplus >= 201103L && TARGET_OS_IPHONE
  25. using std::any_of;      // Section 25.2.2
  26. #else
  27. /// \fn any_of ( InputIterator first, InputIterator last, Predicate p )
  28. /// \return true if any of the elements in [first, last) satisfy the predicate
  29. /// \note returns false on an empty range
  30. ///
  31. /// \param first The start of the input sequence
  32. /// \param last  One past the end of the input sequence
  33. /// \param p     A predicate for testing the elements of the sequence
  34. ///
  35. template<typename InputIterator, typename Predicate>
  36. bool any_of ( InputIterator first, InputIterator last, Predicate p )
  37. {
  38.     for ( ; first != last; ++first )
  39.         if ( p(*first))
  40.             return true;
  41.     return false;
  42. }
  43. #endif
  44.  
  45. /// \fn any_of ( const Range &r, Predicate p )
  46. /// \return true if any elements in the range satisfy the predicate 'p'
  47. /// \note returns false on an empty range
  48. ///
  49. /// \param r    The input range
  50. /// \param p    A predicate for testing the elements of the range
  51. ///
  52. template<typename Range, typename Predicate>
  53. bool any_of ( const Range &r, Predicate p )
  54. {
  55.     return mars_boost::algorithm::any_of (mars_boost::begin (r), mars_boost::end (r), p);
  56. }
  57.  
  58. /// \fn any_of_equal ( InputIterator first, InputIterator last, const V &val )
  59. /// \return true if any of the elements in [first, last) are equal to 'val'
  60. /// \note returns false on an empty range
  61. ///
  62. /// \param first The start of the input sequence
  63. /// \param last  One past the end of the input sequence
  64. /// \param val   A value to compare against
  65. ///
  66. template<typename InputIterator, typename V>
  67. bool any_of_equal ( InputIterator first, InputIterator last, const V &val )
  68. {
  69.     for ( ; first != last; ++first )
  70.         if ( val == *first )
  71.             return true;
  72.     return false;
  73. }
  74.  
  75. /// \fn any_of_equal ( const Range &r, const V &val )
  76. /// \return true if any of the elements in the range are equal to 'val'
  77. /// \note returns false on an empty range
  78. ///
  79. /// \param r     The input range
  80. /// \param val   A value to compare against
  81. ///
  82. template<typename Range, typename V>
  83. bool any_of_equal ( const Range &r, const V &val )
  84. {
  85.     return mars_boost::algorithm::any_of_equal (mars_boost::begin (r), mars_boost::end (r), val);
  86. }
  87.  
  88. }} // namespace boost and algorithm
  89.  
  90. #endif // BOOST_ALGORITHM_ANY_OF_HPP
  91.  
downloadany_of.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top