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