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
,void*> >
34 class ptr_unordered_map
:
35 public ptr_map_adapter
<T
,boost::unordered_map
<Key
,void*,Hash
,Pred
,Allocator
>,
38 typedef ptr_map_adapter
<T
,boost::unordered_map
<Key
,void*,Hash
,Pred
,Allocator
>,
42 typedef ptr_unordered_map
<Key
,T
,Hash
,Pred
,CloneAllocator
,Allocator
> this_type
;
45 typedef typename
base_type::size_type size_type
;
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
;
60 using base_type::begin
;
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
;
78 explicit ptr_unordered_map( size_type n
)
79 : base_type( n
, ptr_container_detail::unordered_associative_container_tag() )
82 ptr_unordered_map( size_type n
,
84 const Pred
& pred
= Pred(),
85 const Allocator
& a
= Allocator() )
86 : base_type( n
, comp
, pred
, a
)
89 template< typename InputIterator
>
90 ptr_unordered_map( InputIterator first
, InputIterator last
)
91 : base_type( first
, last
)
94 template< typename InputIterator
>
95 ptr_unordered_map( InputIterator first
, InputIterator last
,
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
,
107 ptr_unordered_map( const ptr_unordered_map
<Key
,U
>& r
) : base_type( r
)
110 ptr_unordered_map
& operator=( ptr_unordered_map r
)
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>
136 typedef ptr_unordered_multimap
<Key
,T
,Hash
,Pred
,CloneAllocator
,Allocator
> this_type
;
139 typedef typename
base_type::size_type size_type
;
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
;
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
;
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
,
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
,
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
,
201 ptr_unordered_multimap( const ptr_unordered_multimap
<Key
,U
>& r
) : base_type( r
)
204 ptr_unordered_multimap
& operator=( ptr_unordered_multimap r
)
211 //////////////////////////////////////////////////////////////////////////////
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 /////////////////////////////////////////////////////////////////////////
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
)
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
)