2 // Boost.Pointer Container
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)
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)
19 #include <boost/unordered_map.hpp>
20 #include <boost/ptr_container/ptr_map_adapter.hpp>
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> >
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>,
40 typedef ptr_map_adapter<T,boost::unordered_map<Key,
41 typename ptr_container_detail::void_ptr<T>::type,Hash,Pred,Allocator>,
45 typedef ptr_unordered_map<Key,T,Hash,Pred,CloneAllocator,Allocator> this_type;
48 typedef typename base_type::size_type size_type;
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;
63 using base_type::begin;
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;
81 explicit ptr_unordered_map( size_type n )
82 : base_type( n, ptr_container_detail::unordered_associative_container_tag() )
85 ptr_unordered_map( size_type n,
87 const Pred& pred = Pred(),
88 const Allocator& a = Allocator() )
89 : base_type( n, comp, pred, a )
92 template< typename InputIterator >
93 ptr_unordered_map( InputIterator first, InputIterator last )
94 : base_type( first, last )
97 template< typename InputIterator >
98 ptr_unordered_map( InputIterator first, InputIterator last,
100 const Pred& pred = Pred(),
101 const Allocator& a = Allocator() )
102 : base_type( first, last, comp, pred, a )
105 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_map,
110 ptr_unordered_map( const ptr_unordered_map<Key,U>& r ) : base_type( r )
113 ptr_unordered_map& operator=( ptr_unordered_map r )
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*> >
131 class ptr_unordered_multimap :
132 public ptr_multimap_adapter<T,boost::unordered_multimap<Key,void*,Hash,Pred,Allocator>,
133 CloneAllocator,false>
135 typedef ptr_multimap_adapter<T,boost::unordered_multimap<Key,void*,Hash,Pred,Allocator>,
136 CloneAllocator,false>
139 typedef ptr_unordered_multimap<Key,T,Hash,Pred,CloneAllocator,Allocator> this_type;
142 typedef typename base_type::size_type size_type;
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;
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;
172 ptr_unordered_multimap()
175 explicit ptr_unordered_multimap( size_type n )
176 : base_type( n, ptr_container_detail::unordered_associative_container_tag() )
179 ptr_unordered_multimap( size_type n,
181 const Pred& pred = Pred(),
182 const Allocator& a = Allocator() )
183 : base_type( n, comp, pred, a )
186 template< typename InputIterator >
187 ptr_unordered_multimap( InputIterator first, InputIterator last )
188 : base_type( first, last )
191 template< typename InputIterator >
192 ptr_unordered_multimap( InputIterator first, InputIterator last,
194 const Pred& pred = Pred(),
195 const Allocator& a = Allocator() )
196 : base_type( first, last, comp, pred, a )
199 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_multimap,
204 ptr_unordered_multimap( const ptr_unordered_multimap<Key,U>& r ) : base_type( r )
207 ptr_unordered_multimap& operator=( ptr_unordered_multimap r )
214 //////////////////////////////////////////////////////////////////////////////
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 )
221 return r.clone().release();
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 )
228 return r.clone().release();
231 /////////////////////////////////////////////////////////////////////////
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 )
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 )