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