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_SET_HPP
13 #define BOOST_PTR_CONTAINER_PTR_UNORDERED_SET_HPP
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
19 #include <boost/ptr_container/indirect_fun.hpp>
20 #include <boost/ptr_container/ptr_set_adapter.hpp>
21 #include <boost/unordered_set.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
<void*>
34 class ptr_unordered_set
:
35 public ptr_set_adapter
< Key
,
36 boost::unordered_set
<void*,void_ptr_indirect_fun
<Hash
,Key
>,
37 void_ptr_indirect_fun
<Pred
,Key
>,Allocator
>,
38 CloneAllocator
, false >
40 typedef ptr_set_adapter
< Key
,
41 boost::unordered_set
<void*,void_ptr_indirect_fun
<Hash
,Key
>,
42 void_ptr_indirect_fun
<Pred
,Key
>,Allocator
>,
43 CloneAllocator
, false >
46 typedef ptr_unordered_set
<Key
,Hash
,Pred
,CloneAllocator
,Allocator
> this_type
;
49 typedef typename
base_type::size_type size_type
;
52 using base_type::lower_bound
;
53 using base_type::upper_bound
;
54 using base_type::rbegin
;
55 using base_type::rend
;
56 using base_type::crbegin
;
57 using base_type::crend
;
58 using base_type::key_comp
;
59 using base_type::value_comp
;
60 using base_type::front
;
61 using base_type::back
;
64 using base_type::begin
;
66 using base_type::cbegin
;
67 using base_type::cend
;
68 using base_type::bucket_count
;
69 using base_type::max_bucket_count
;
70 using base_type::bucket_size
;
71 using base_type::bucket
;
72 using base_type::load_factor
;
73 using base_type::max_load_factor
;
74 using base_type::rehash
;
75 using base_type::key_eq
;
76 using base_type::hash_function
;
82 explicit ptr_unordered_set( size_type n
)
83 : base_type( n
, ptr_container_detail::unordered_associative_container_tag() )
86 ptr_unordered_set( size_type n
,
88 const Pred
& pred
= Pred(),
89 const Allocator
& a
= Allocator() )
90 : base_type( n
, comp
, pred
, a
)
93 template< typename InputIterator
>
94 ptr_unordered_set( InputIterator first
, InputIterator last
)
95 : base_type( first
, last
)
98 template< typename InputIterator
>
99 ptr_unordered_set( InputIterator first
, InputIterator last
,
101 const Pred
& pred
= Pred(),
102 const Allocator
& a
= Allocator() )
103 : base_type( first
, last
, comp
, pred
, a
)
106 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_set
,
110 BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_unordered_set
,
119 class Hash
= boost::hash
<Key
>,
120 class Pred
= std::equal_to
<Key
>,
121 class CloneAllocator
= heap_clone_allocator
,
122 class Allocator
= std::allocator
<void*>
124 class ptr_unordered_multiset
:
125 public ptr_multiset_adapter
< Key
,
126 boost::unordered_multiset
<void*,void_ptr_indirect_fun
<Hash
,Key
>,
127 void_ptr_indirect_fun
<Pred
,Key
>,Allocator
>,
128 CloneAllocator
, false >
130 typedef ptr_multiset_adapter
< Key
,
131 boost::unordered_multiset
<void*,void_ptr_indirect_fun
<Hash
,Key
>,
132 void_ptr_indirect_fun
<Pred
,Key
>,Allocator
>,
133 CloneAllocator
, false >
135 typedef ptr_unordered_multiset
<Key
,Hash
,Pred
,CloneAllocator
,Allocator
> this_type
;
138 typedef typename
base_type::size_type size_type
;
141 using base_type::lower_bound
;
142 using base_type::upper_bound
;
143 using base_type::rbegin
;
144 using base_type::rend
;
145 using base_type::crbegin
;
146 using base_type::crend
;
147 using base_type::key_comp
;
148 using base_type::value_comp
;
149 using base_type::front
;
150 using base_type::back
;
153 using base_type::begin
;
154 using base_type::end
;
155 using base_type::cbegin
;
156 using base_type::cend
;
157 using base_type::bucket_count
;
158 using base_type::max_bucket_count
;
159 using base_type::bucket_size
;
160 using base_type::bucket
;
161 using base_type::load_factor
;
162 using base_type::max_load_factor
;
163 using base_type::rehash
;
164 using base_type::key_eq
;
165 using base_type::hash_function
;
168 ptr_unordered_multiset()
171 explicit ptr_unordered_multiset( size_type n
)
172 : base_type( n
, ptr_container_detail::unordered_associative_container_tag() )
175 ptr_unordered_multiset( size_type n
,
177 const Pred
& pred
= Pred(),
178 const Allocator
& a
= Allocator() )
179 : base_type( n
, comp
, pred
, a
)
182 template< typename InputIterator
>
183 ptr_unordered_multiset( InputIterator first
, InputIterator last
)
184 : base_type( first
, last
)
187 template< typename InputIterator
>
188 ptr_unordered_multiset( InputIterator first
, InputIterator last
,
190 const Pred
& pred
= Pred(),
191 const Allocator
& a
= Allocator() )
192 : base_type( first
, last
, comp
, pred
, a
)
195 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_multiset
,
199 BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_unordered_multiset
,
204 /////////////////////////////////////////////////////////////////////////
207 template< typename K
, typename H
, typename P
, typename CA
, typename A
>
208 inline ptr_unordered_set
<K
,H
,P
,CA
,A
>*
209 new_clone( const ptr_unordered_set
<K
,H
,P
,CA
,A
>& r
)
211 return r
.clone().release();
214 template< typename K
, typename H
, typename P
, typename CA
, typename A
>
215 inline ptr_unordered_multiset
<K
,H
,P
,CA
,A
>*
216 new_clone( const ptr_unordered_multiset
<K
,H
,P
,CA
,A
>& r
)
218 return r
.clone().release();
221 /////////////////////////////////////////////////////////////////////////
224 template< typename K
, typename H
, typename P
, typename CA
, typename A
>
225 inline void swap( ptr_unordered_set
<K
,H
,P
,CA
,A
>& l
,
226 ptr_unordered_set
<K
,H
,P
,CA
,A
>& r
)
231 template< typename K
, typename H
, typename P
, typename CA
, typename A
>
232 inline void swap( ptr_unordered_multiset
<K
,H
,P
,CA
,A
>& l
,
233 ptr_unordered_multiset
<K
,H
,P
,CA
,A
>& r
)