]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph/include/boost/graph/detail/set_adaptor.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / graph / include / boost / graph / detail / set_adaptor.hpp
1 // (C) Copyright Jeremy Siek 2001.
2 // Distributed under the Boost Software License, Version 1.0. (See
3 // accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5
6 #ifndef BOOST_SET_ADAPTOR_HPP
7 #define BOOST_SET_ADAPTOR_HPP
8
9 #include <set>
10 #include <boost/unordered_set.hpp>
11
12 namespace boost {
13
14 template <class K, class C, class A, class T>
15 bool set_contains(const std::set<K,C,A>& s, const T& x) {
16 return s.find(x) != s.end();
17 }
18
19 template <class K, class H, class C, class A, class T>
20 bool set_contains(const boost::unordered_set<K,H,C,A>& s, const T& x) {
21 return s.find(x) != s.end();
22 }
23
24 template <class K, class C, class A>
25 bool set_equal(const std::set<K,C,A>& x,
26 const std::set<K,C,A>& y)
27 {
28 return x == y;
29 }
30
31 // Not the same as lexicographical_compare_3way applied to std::set.
32 // this is equivalent semantically to bitset::operator<()
33 template <class K, class C, class A>
34 int set_lex_order(const std::set<K,C,A>& x,
35 const std::set<K,C,A>& y)
36 {
37 typename std::set<K,C,A>::iterator
38 xi = x.begin(), yi = y.begin(), xend = x.end(), yend = y.end();
39 for (; xi != xend && yi != yend; ++xi, ++yi) {
40 if (*xi < *yi)
41 return 1;
42 else if (*yi < *xi)
43 return -1;
44 }
45 if (xi == xend)
46 return (yi == yend) ? 0 : -1;
47 else
48 return 1;
49 }
50
51 template <class K, class C, class A>
52 void set_clear(std::set<K,C,A>& x) {
53 x.clear();
54 }
55
56 template <class K, class C, class A>
57 bool set_empty(const std::set<K,C,A>& x) {
58 return x.empty();
59 }
60
61 template <class K, class C, class A, class T>
62 void set_insert(std::set<K,C,A>& x, const T& a) {
63 x.insert(a);
64 }
65
66 template <class K, class C, class A, class T>
67 void set_remove(std::set<K,C,A>& x, const T& a) {
68 x.erase(a);
69 }
70
71 template <class K, class C, class A>
72 void set_intersect(const std::set<K,C,A>& x,
73 const std::set<K,C,A>& y,
74 std::set<K,C,A>& z)
75 {
76 z.clear();
77 std::set_intersection(x.begin(), x.end(),
78 y.begin(), y.end(),
79 std::inserter(z));
80 }
81
82 template <class K, class C, class A>
83 void set_union(const std::set<K,C,A>& x,
84 const std::set<K,C,A>& y,
85 std::set<K,C,A>& z)
86 {
87 z.clear();
88 std::set_union(x.begin(), x.end(),
89 y.begin(), y.end(),
90 std::inserter(z));
91 }
92
93 template <class K, class C, class A>
94 void set_difference(const std::set<K,C,A>& x,
95 const std::set<K,C,A>& y,
96 std::set<K,C,A>& z)
97 {
98 z.clear();
99 std::set_difference(x.begin(), x.end(),
100 y.begin(), y.end(),
101 std::inserter(z, z.begin()));
102 }
103
104 template <class K, class C, class A>
105 bool set_subset(const std::set<K,C,A>& x,
106 const std::set<K,C,A>& y)
107 {
108 return std::includes(x.begin(), x.end(), y.begin(), y.end());
109 }
110
111 // Shit, can't implement this without knowing the size of the
112 // universe.
113 template <class K, class C, class A>
114 void set_compliment(const std::set<K,C,A>& /*x*/,
115 std::set<K,C,A>& z)
116 {
117 z.clear();
118
119 }
120
121 } // namespace boost
122
123 #endif // BOOST_SET_ADAPTOR_HPP