algorithm.hpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. # include <boost/detail/iterator.hpp>
  32. // Algorithms on sequences
  33. //
  34. // The functions in this file have not yet gone through formal
  35. // review, and are subject to change. This is a work in progress.
  36. // They have been checked into the detail directory because
  37. // there are some graph algorithms that use these functions.
  38. #include <algorithm>
  39. #include <vector>
  40. #include <boost/range/begin.hpp>
  41. #include <boost/range/end.hpp>
  42. #include <boost/range/algorithm/copy.hpp>
  43. #include <boost/range/algorithm/equal.hpp>
  44. #include <boost/range/algorithm/sort.hpp>
  45. #include <boost/range/algorithm/stable_sort.hpp>
  46. #include <boost/range/algorithm/find_if.hpp>
  47. #include <boost/range/algorithm/count.hpp>
  48. #include <boost/range/algorithm/count_if.hpp>
  49. #include <boost/range/algorithm_ext/is_sorted.hpp>
  50. #include <boost/range/algorithm_ext/iota.hpp>
  51. namespace boost {
  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