]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/ptr_container/ptr_unordered_set.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / ptr_container / ptr_unordered_set.hpp
1 //
2 // Boost.Pointer Container
3 //
4 // Copyright Thorsten Ottosen 2008. Use, modification and
5 // distribution is subject to the Boost Software License, Version
6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //
9 // For more information, see http://www.boost.org/libs/ptr_container/
10 //
11
12 #ifndef BOOST_PTR_CONTAINER_PTR_UNORDERED_SET_HPP
13 #define BOOST_PTR_CONTAINER_PTR_UNORDERED_SET_HPP
14
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 # pragma once
17 #endif
18
19 #include <boost/ptr_container/indirect_fun.hpp>
20 #include <boost/ptr_container/ptr_set_adapter.hpp>
21 #include <boost/unordered_set.hpp>
22
23 namespace boost
24 {
25
26 template
27 <
28 class Key,
29 class Hash = boost::hash<Key>,
30 class Pred = std::equal_to<Key>,
31 class CloneAllocator = heap_clone_allocator,
32 class Allocator = std::allocator< typename ptr_container_detail::void_ptr<Key>::type >
33 >
34 class ptr_unordered_set :
35 public ptr_set_adapter< Key, boost::unordered_set<
36 typename ptr_container_detail::void_ptr<Key>::type,
37 void_ptr_indirect_fun<Hash,Key>,
38 void_ptr_indirect_fun<Pred,Key>,Allocator>,
39 CloneAllocator, false >
40 {
41 typedef ptr_set_adapter< Key, boost::unordered_set<
42 typename ptr_container_detail::void_ptr<Key>::type,
43 void_ptr_indirect_fun<Hash,Key>,
44 void_ptr_indirect_fun<Pred,Key>,Allocator>,
45 CloneAllocator, false >
46 base_type;
47
48 typedef ptr_unordered_set<Key,Hash,Pred,CloneAllocator,Allocator> this_type;
49
50 public:
51 typedef typename base_type::size_type size_type;
52
53 private:
54 using base_type::lower_bound;
55 using base_type::upper_bound;
56 using base_type::rbegin;
57 using base_type::rend;
58 using base_type::crbegin;
59 using base_type::crend;
60 using base_type::key_comp;
61 using base_type::value_comp;
62 using base_type::front;
63 using base_type::back;
64
65 public:
66 using base_type::begin;
67 using base_type::end;
68 using base_type::cbegin;
69 using base_type::cend;
70 using base_type::bucket_count;
71 using base_type::max_bucket_count;
72 using base_type::bucket_size;
73 using base_type::bucket;
74 using base_type::load_factor;
75 using base_type::max_load_factor;
76 using base_type::rehash;
77 using base_type::key_eq;
78 using base_type::hash_function;
79
80 public:
81 ptr_unordered_set()
82 {}
83
84 explicit ptr_unordered_set( size_type n )
85 : base_type( n, ptr_container_detail::unordered_associative_container_tag() )
86 { }
87
88 ptr_unordered_set( size_type n,
89 const Hash& comp,
90 const Pred& pred = Pred(),
91 const Allocator& a = Allocator() )
92 : base_type( n, comp, pred, a )
93 { }
94
95 template< typename InputIterator >
96 ptr_unordered_set( InputIterator first, InputIterator last )
97 : base_type( first, last )
98 { }
99
100 template< typename InputIterator >
101 ptr_unordered_set( InputIterator first, InputIterator last,
102 const Hash& comp,
103 const Pred& pred = Pred(),
104 const Allocator& a = Allocator() )
105 : base_type( first, last, comp, pred, a )
106 { }
107
108 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_set,
109 base_type,
110 this_type )
111
112 BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_unordered_set,
113 base_type )
114
115 };
116
117
118 template
119 <
120 class Key,
121 class Hash = boost::hash<Key>,
122 class Pred = std::equal_to<Key>,
123 class CloneAllocator = heap_clone_allocator,
124 class Allocator = std::allocator<void*>
125 >
126 class ptr_unordered_multiset :
127 public ptr_multiset_adapter< Key,
128 boost::unordered_multiset<void*,void_ptr_indirect_fun<Hash,Key>,
129 void_ptr_indirect_fun<Pred,Key>,Allocator>,
130 CloneAllocator, false >
131 {
132 typedef ptr_multiset_adapter< Key,
133 boost::unordered_multiset<void*,void_ptr_indirect_fun<Hash,Key>,
134 void_ptr_indirect_fun<Pred,Key>,Allocator>,
135 CloneAllocator, false >
136 base_type;
137 typedef ptr_unordered_multiset<Key,Hash,Pred,CloneAllocator,Allocator> this_type;
138
139 public:
140 typedef typename base_type::size_type size_type;
141
142 private:
143 using base_type::lower_bound;
144 using base_type::upper_bound;
145 using base_type::rbegin;
146 using base_type::rend;
147 using base_type::crbegin;
148 using base_type::crend;
149 using base_type::key_comp;
150 using base_type::value_comp;
151 using base_type::front;
152 using base_type::back;
153
154 public:
155 using base_type::begin;
156 using base_type::end;
157 using base_type::cbegin;
158 using base_type::cend;
159 using base_type::bucket_count;
160 using base_type::max_bucket_count;
161 using base_type::bucket_size;
162 using base_type::bucket;
163 using base_type::load_factor;
164 using base_type::max_load_factor;
165 using base_type::rehash;
166 using base_type::key_eq;
167 using base_type::hash_function;
168
169 public:
170 ptr_unordered_multiset()
171 { }
172
173 explicit ptr_unordered_multiset( size_type n )
174 : base_type( n, ptr_container_detail::unordered_associative_container_tag() )
175 { }
176
177 ptr_unordered_multiset( size_type n,
178 const Hash& comp,
179 const Pred& pred = Pred(),
180 const Allocator& a = Allocator() )
181 : base_type( n, comp, pred, a )
182 { }
183
184 template< typename InputIterator >
185 ptr_unordered_multiset( InputIterator first, InputIterator last )
186 : base_type( first, last )
187 { }
188
189 template< typename InputIterator >
190 ptr_unordered_multiset( InputIterator first, InputIterator last,
191 const Hash& comp,
192 const Pred& pred = Pred(),
193 const Allocator& a = Allocator() )
194 : base_type( first, last, comp, pred, a )
195 { }
196
197 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_multiset,
198 base_type,
199 this_type )
200
201 BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_unordered_multiset,
202 base_type )
203
204 };
205
206 /////////////////////////////////////////////////////////////////////////
207 // clonability
208
209 template< typename K, typename H, typename P, typename CA, typename A >
210 inline ptr_unordered_set<K,H,P,CA,A>*
211 new_clone( const ptr_unordered_set<K,H,P,CA,A>& r )
212 {
213 return r.clone().release();
214 }
215
216 template< typename K, typename H, typename P, typename CA, typename A >
217 inline ptr_unordered_multiset<K,H,P,CA,A>*
218 new_clone( const ptr_unordered_multiset<K,H,P,CA,A>& r )
219 {
220 return r.clone().release();
221 }
222
223 /////////////////////////////////////////////////////////////////////////
224 // swap
225
226 template< typename K, typename H, typename P, typename CA, typename A >
227 inline void swap( ptr_unordered_set<K,H,P,CA,A>& l,
228 ptr_unordered_set<K,H,P,CA,A>& r )
229 {
230 l.swap(r);
231 }
232
233 template< typename K, typename H, typename P, typename CA, typename A >
234 inline void swap( ptr_unordered_multiset<K,H,P,CA,A>& l,
235 ptr_unordered_multiset<K,H,P,CA,A>& r )
236 {
237 l.swap(r);
238 }
239
240 }
241
242 #endif