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< typename ptr_container_detail::void_ptr<Key>::type >
34 class ptr_unordered_set :
35 public ptr_set_adapter< Key, boost::unordered_set<
36 typename ptr_container_detail::void_ptr<Key>::type,
37 void_ptr_indirect_fun<Hash,Key>,
38 void_ptr_indirect_fun<Pred,Key>,Allocator>,
39 CloneAllocator, false >
41 typedef ptr_set_adapter< Key, boost::unordered_set<
42 typename ptr_container_detail::void_ptr<Key>::type,
43 void_ptr_indirect_fun<Hash,Key>,
44 void_ptr_indirect_fun<Pred,Key>,Allocator>,
45 CloneAllocator, false >
48 typedef ptr_unordered_set<Key,Hash,Pred,CloneAllocator,Allocator> this_type;
51 typedef typename base_type::size_type size_type;
54 using base_type::lower_bound;
55 using base_type::upper_bound;
56 using base_type::rbegin;
57 using base_type::rend;
58 using base_type::crbegin;
59 using base_type::crend;
60 using base_type::key_comp;
61 using base_type::value_comp;
62 using base_type::front;
63 using base_type::back;
66 using base_type::begin;
68 using base_type::cbegin;
69 using base_type::cend;
70 using base_type::bucket_count;
71 using base_type::max_bucket_count;
72 using base_type::bucket_size;
73 using base_type::bucket;
74 using base_type::load_factor;
75 using base_type::max_load_factor;
76 using base_type::rehash;
77 using base_type::key_eq;
78 using base_type::hash_function;
84 explicit ptr_unordered_set( size_type n )
85 : base_type( n, ptr_container_detail::unordered_associative_container_tag() )
88 ptr_unordered_set( size_type n,
90 const Pred& pred = Pred(),
91 const Allocator& a = Allocator() )
92 : base_type( n, comp, pred, a )
95 template< typename InputIterator >
96 ptr_unordered_set( InputIterator first, InputIterator last )
97 : base_type( first, last )
100 template< typename InputIterator >
101 ptr_unordered_set( InputIterator first, InputIterator last,
103 const Pred& pred = Pred(),
104 const Allocator& a = Allocator() )
105 : base_type( first, last, comp, pred, a )
108 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_set,
112 BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_unordered_set,
121 class Hash = boost::hash<Key>,
122 class Pred = std::equal_to<Key>,
123 class CloneAllocator = heap_clone_allocator,
124 class Allocator = std::allocator<void*>
126 class ptr_unordered_multiset :
127 public ptr_multiset_adapter< Key,
128 boost::unordered_multiset<void*,void_ptr_indirect_fun<Hash,Key>,
129 void_ptr_indirect_fun<Pred,Key>,Allocator>,
130 CloneAllocator, false >
132 typedef ptr_multiset_adapter< Key,
133 boost::unordered_multiset<void*,void_ptr_indirect_fun<Hash,Key>,
134 void_ptr_indirect_fun<Pred,Key>,Allocator>,
135 CloneAllocator, false >
137 typedef ptr_unordered_multiset<Key,Hash,Pred,CloneAllocator,Allocator> this_type;
140 typedef typename base_type::size_type size_type;
143 using base_type::lower_bound;
144 using base_type::upper_bound;
145 using base_type::rbegin;
146 using base_type::rend;
147 using base_type::crbegin;
148 using base_type::crend;
149 using base_type::key_comp;
150 using base_type::value_comp;
151 using base_type::front;
152 using base_type::back;
155 using base_type::begin;
156 using base_type::end;
157 using base_type::cbegin;
158 using base_type::cend;
159 using base_type::bucket_count;
160 using base_type::max_bucket_count;
161 using base_type::bucket_size;
162 using base_type::bucket;
163 using base_type::load_factor;
164 using base_type::max_load_factor;
165 using base_type::rehash;
166 using base_type::key_eq;
167 using base_type::hash_function;
170 ptr_unordered_multiset()
173 explicit ptr_unordered_multiset( size_type n )
174 : base_type( n, ptr_container_detail::unordered_associative_container_tag() )
177 ptr_unordered_multiset( size_type n,
179 const Pred& pred = Pred(),
180 const Allocator& a = Allocator() )
181 : base_type( n, comp, pred, a )
184 template< typename InputIterator >
185 ptr_unordered_multiset( InputIterator first, InputIterator last )
186 : base_type( first, last )
189 template< typename InputIterator >
190 ptr_unordered_multiset( InputIterator first, InputIterator last,
192 const Pred& pred = Pred(),
193 const Allocator& a = Allocator() )
194 : base_type( first, last, comp, pred, a )
197 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_multiset,
201 BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_unordered_multiset,
206 /////////////////////////////////////////////////////////////////////////
209 template< typename K, typename H, typename P, typename CA, typename A >
210 inline ptr_unordered_set<K,H,P,CA,A>*
211 new_clone( const ptr_unordered_set<K,H,P,CA,A>& r )
213 return r.clone().release();
216 template< typename K, typename H, typename P, typename CA, typename A >
217 inline ptr_unordered_multiset<K,H,P,CA,A>*
218 new_clone( const ptr_unordered_multiset<K,H,P,CA,A>& r )
220 return r.clone().release();
223 /////////////////////////////////////////////////////////////////////////
226 template< typename K, typename H, typename P, typename CA, typename A >
227 inline void swap( ptr_unordered_set<K,H,P,CA,A>& l,
228 ptr_unordered_set<K,H,P,CA,A>& r )
233 template< typename K, typename H, typename P, typename CA, typename A >
234 inline void swap( ptr_unordered_multiset<K,H,P,CA,A>& l,
235 ptr_unordered_multiset<K,H,P,CA,A>& r )