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

source code of boost/boost/ptr_container/ptr_unordered_map.hpp