fix doc example typo
[boost.git] / boost / ptr_container / ptr_unordered_map.hpp
blobb881584a42d7c544f16c794801578a45b7e32abd
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/
12 #ifndef BOOST_PTR_CONTAINER_PTR_UNORDERED_MAP_HPP
13 #define BOOST_PTR_CONTAINER_PTR_UNORDERED_MAP_HPP
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 # pragma once
17 #endif
19 #include <boost/unordered_map.hpp>
20 #include <boost/ptr_container/ptr_map_adapter.hpp>
22 namespace boost
25 template
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*> >
34 class ptr_unordered_map :
35 public ptr_map_adapter<T,boost::unordered_map<Key,void*,Hash,Pred,Allocator>,
36 CloneAllocator,false>
38 typedef ptr_map_adapter<T,boost::unordered_map<Key,void*,Hash,Pred,Allocator>,
39 CloneAllocator,false>
40 base_type;
42 typedef ptr_unordered_map<Key,T,Hash,Pred,CloneAllocator,Allocator> this_type;
44 public:
45 typedef typename base_type::size_type size_type;
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;
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;
74 public:
75 ptr_unordered_map()
76 { }
78 explicit ptr_unordered_map( size_type n )
79 : base_type( n, ptr_container_detail::unordered_associative_container_tag() )
80 { }
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 { }
89 template< typename InputIterator >
90 ptr_unordered_map( InputIterator first, InputIterator last )
91 : base_type( first, last )
92 { }
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 )
102 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_map,
103 base_type,
104 this_type )
106 template< class U >
107 ptr_unordered_map( const ptr_unordered_map<Key,U>& r ) : base_type( r )
110 ptr_unordered_map& operator=( ptr_unordered_map r )
112 this->swap( r );
113 return *this;
119 template
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*> >
128 class ptr_unordered_multimap :
129 public ptr_multimap_adapter<T,boost::unordered_multimap<Key,void*,Hash,Pred,Allocator>,
130 CloneAllocator,false>
132 typedef ptr_multimap_adapter<T,boost::unordered_multimap<Key,void*,Hash,Pred,Allocator>,
133 CloneAllocator,false>
134 base_type;
136 typedef ptr_unordered_multimap<Key,T,Hash,Pred,CloneAllocator,Allocator> this_type;
138 public:
139 typedef typename base_type::size_type size_type;
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;
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;
168 public:
169 ptr_unordered_multimap()
172 explicit ptr_unordered_multimap( size_type n )
173 : base_type( n, ptr_container_detail::unordered_associative_container_tag() )
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 )
183 template< typename InputIterator >
184 ptr_unordered_multimap( InputIterator first, InputIterator last )
185 : base_type( first, last )
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 )
196 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_multimap,
197 base_type,
198 this_type )
200 template< class U >
201 ptr_unordered_multimap( const ptr_unordered_multimap<Key,U>& r ) : base_type( r )
204 ptr_unordered_multimap& operator=( ptr_unordered_multimap r )
206 this->swap( r );
207 return *this;
211 //////////////////////////////////////////////////////////////////////////////
212 // clonability
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 )
218 return r.clone().release();
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 )
225 return r.clone().release();
228 /////////////////////////////////////////////////////////////////////////
229 // swap
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 )
235 l.swap(r);
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 )
242 l.swap(r);
248 #endif