algorithm.hpp 2.9 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. #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. {
  53. template < typename InputIterator, typename Predicate >
  54. bool any_if(InputIterator first, InputIterator last, Predicate p)
  55. {
  56. return std::find_if(first, last, p) != last;
  57. }
  58. template < typename Container, typename Predicate >
  59. bool any_if(const Container& c, Predicate p)
  60. {
  61. return any_if(boost::begin(c), boost::end(c), p);
  62. }
  63. template < typename InputIterator, typename T >
  64. bool container_contains(InputIterator first, InputIterator last, T value)
  65. {
  66. return std::find(first, last, value) != last;
  67. }
  68. template < typename Container, typename T >
  69. bool container_contains(const Container& c, const T& value)
  70. {
  71. return container_contains(boost::begin(c), boost::end(c), value);
  72. }
  73. } // namespace boost
  74. #endif // BOOST_ALGORITHM_HPP