algorithm.hpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // (C) Copyright Jeremy Siek 2001.
  2. // Distributed under the Boost Software License, Version 1.0. (See accompany-
  3. // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. /*
  5. *
  6. * Copyright (c) 1994
  7. * Hewlett-Packard Company
  8. *
  9. * Permission to use, copy, modify, distribute and sell this software
  10. * and its documentation for any purpose is hereby granted without fee,
  11. * provided that the above copyright notice appear in all copies and
  12. * that both that copyright notice and this permission notice appear
  13. * in supporting documentation. Hewlett-Packard Company makes no
  14. * representations about the suitability of this software for any
  15. * purpose. It is provided "as is" without express or implied warranty.
  16. *
  17. *
  18. * Copyright (c) 1996
  19. * Silicon Graphics Computer Systems, Inc.
  20. *
  21. * Permission to use, copy, modify, distribute and sell this software
  22. * and its documentation for any purpose is hereby granted without fee,
  23. * provided that the above copyright notice appear in all copies and
  24. * that both that copyright notice and this permission notice appear
  25. * in supporting documentation. Silicon Graphics makes no
  26. * representations about the suitability of this software for any
  27. * purpose. It is provided "as is" without express or implied warranty.
  28. */
  29. #ifndef BOOST_ALGORITHM_HPP
  30. #define BOOST_ALGORITHM_HPP
  31. // Algorithms on sequences
  32. //
  33. // The functions in this file have not yet gone through formal
  34. // review, and are subject to change. This is a work in progress.
  35. // They have been checked into the detail directory because
  36. // there are some graph algorithms that use these functions.
  37. #include <algorithm>
  38. #include <vector>
  39. #include <boost/range/begin.hpp>
  40. #include <boost/range/end.hpp>
  41. #include <boost/range/algorithm/copy.hpp>
  42. #include <boost/range/algorithm/equal.hpp>
  43. #include <boost/range/algorithm/sort.hpp>
  44. #include <boost/range/algorithm/stable_sort.hpp>
  45. #include <boost/range/algorithm/find_if.hpp>
  46. #include <boost/range/algorithm/count.hpp>
  47. #include <boost/range/algorithm/count_if.hpp>
  48. #include <boost/range/algorithm_ext/is_sorted.hpp>
  49. #include <boost/range/algorithm_ext/iota.hpp>
  50. namespace boost
  51. {
  52. template < typename InputIterator, typename Predicate >
  53. bool any_if(InputIterator first, InputIterator last, Predicate p)
  54. {
  55. return std::find_if(first, last, p) != last;
  56. }
  57. template < typename Container, typename Predicate >
  58. bool any_if(const Container& c, Predicate p)
  59. {
  60. return any_if(boost::begin(c), boost::end(c), p);
  61. }
  62. template < typename InputIterator, typename T >
  63. bool container_contains(InputIterator first, InputIterator last, T value)
  64. {
  65. return std::find(first, last, value) != last;
  66. }
  67. template < typename Container, typename T >
  68. bool container_contains(const Container& c, const T& value)
  69. {
  70. return container_contains(boost::begin(c), boost::end(c), value);
  71. }
  72. } // namespace boost
  73. #endif // BOOST_ALGORITHM_HPP