Chris@16
|
1 //
|
Chris@16
|
2 // Boost.Pointer Container
|
Chris@16
|
3 //
|
Chris@16
|
4 // Copyright Thorsten Ottosen 2008. Use, modification and
|
Chris@16
|
5 // distribution is subject to the Boost Software License, Version
|
Chris@16
|
6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8 //
|
Chris@16
|
9 // For more information, see http://www.boost.org/libs/ptr_container/
|
Chris@16
|
10 //
|
Chris@16
|
11
|
Chris@16
|
12 #ifndef BOOST_PTR_CONTAINER_PTR_UNORDERED_SET_HPP
|
Chris@16
|
13 #define BOOST_PTR_CONTAINER_PTR_UNORDERED_SET_HPP
|
Chris@16
|
14
|
Chris@16
|
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
16 # pragma once
|
Chris@16
|
17 #endif
|
Chris@16
|
18
|
Chris@16
|
19 #include <boost/ptr_container/indirect_fun.hpp>
|
Chris@16
|
20 #include <boost/ptr_container/ptr_set_adapter.hpp>
|
Chris@16
|
21 #include <boost/unordered_set.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 namespace boost
|
Chris@16
|
24 {
|
Chris@16
|
25
|
Chris@16
|
26 template
|
Chris@16
|
27 <
|
Chris@16
|
28 class Key,
|
Chris@16
|
29 class Hash = boost::hash<Key>,
|
Chris@16
|
30 class Pred = std::equal_to<Key>,
|
Chris@16
|
31 class CloneAllocator = heap_clone_allocator,
|
Chris@16
|
32 class Allocator = std::allocator<void*>
|
Chris@16
|
33 >
|
Chris@16
|
34 class ptr_unordered_set :
|
Chris@16
|
35 public ptr_set_adapter< Key,
|
Chris@16
|
36 boost::unordered_set<void*,void_ptr_indirect_fun<Hash,Key>,
|
Chris@16
|
37 void_ptr_indirect_fun<Pred,Key>,Allocator>,
|
Chris@16
|
38 CloneAllocator, false >
|
Chris@16
|
39 {
|
Chris@16
|
40 typedef ptr_set_adapter< Key,
|
Chris@16
|
41 boost::unordered_set<void*,void_ptr_indirect_fun<Hash,Key>,
|
Chris@16
|
42 void_ptr_indirect_fun<Pred,Key>,Allocator>,
|
Chris@16
|
43 CloneAllocator, false >
|
Chris@16
|
44 base_type;
|
Chris@16
|
45
|
Chris@16
|
46 typedef ptr_unordered_set<Key,Hash,Pred,CloneAllocator,Allocator> this_type;
|
Chris@16
|
47
|
Chris@16
|
48 public:
|
Chris@16
|
49 typedef typename base_type::size_type size_type;
|
Chris@16
|
50
|
Chris@16
|
51 private:
|
Chris@16
|
52 using base_type::lower_bound;
|
Chris@16
|
53 using base_type::upper_bound;
|
Chris@16
|
54 using base_type::rbegin;
|
Chris@16
|
55 using base_type::rend;
|
Chris@16
|
56 using base_type::crbegin;
|
Chris@16
|
57 using base_type::crend;
|
Chris@16
|
58 using base_type::key_comp;
|
Chris@16
|
59 using base_type::value_comp;
|
Chris@16
|
60 using base_type::front;
|
Chris@16
|
61 using base_type::back;
|
Chris@16
|
62
|
Chris@16
|
63 public:
|
Chris@16
|
64 using base_type::begin;
|
Chris@16
|
65 using base_type::end;
|
Chris@16
|
66 using base_type::cbegin;
|
Chris@16
|
67 using base_type::cend;
|
Chris@16
|
68 using base_type::bucket_count;
|
Chris@16
|
69 using base_type::max_bucket_count;
|
Chris@16
|
70 using base_type::bucket_size;
|
Chris@16
|
71 using base_type::bucket;
|
Chris@16
|
72 using base_type::load_factor;
|
Chris@16
|
73 using base_type::max_load_factor;
|
Chris@16
|
74 using base_type::rehash;
|
Chris@16
|
75 using base_type::key_eq;
|
Chris@16
|
76 using base_type::hash_function;
|
Chris@16
|
77
|
Chris@16
|
78 public:
|
Chris@16
|
79 ptr_unordered_set()
|
Chris@16
|
80 {}
|
Chris@16
|
81
|
Chris@16
|
82 explicit ptr_unordered_set( size_type n )
|
Chris@16
|
83 : base_type( n, ptr_container_detail::unordered_associative_container_tag() )
|
Chris@16
|
84 { }
|
Chris@16
|
85
|
Chris@16
|
86 ptr_unordered_set( size_type n,
|
Chris@16
|
87 const Hash& comp,
|
Chris@16
|
88 const Pred& pred = Pred(),
|
Chris@16
|
89 const Allocator& a = Allocator() )
|
Chris@16
|
90 : base_type( n, comp, pred, a )
|
Chris@16
|
91 { }
|
Chris@16
|
92
|
Chris@16
|
93 template< typename InputIterator >
|
Chris@16
|
94 ptr_unordered_set( InputIterator first, InputIterator last )
|
Chris@16
|
95 : base_type( first, last )
|
Chris@16
|
96 { }
|
Chris@16
|
97
|
Chris@16
|
98 template< typename InputIterator >
|
Chris@16
|
99 ptr_unordered_set( InputIterator first, InputIterator last,
|
Chris@16
|
100 const Hash& comp,
|
Chris@16
|
101 const Pred& pred = Pred(),
|
Chris@16
|
102 const Allocator& a = Allocator() )
|
Chris@16
|
103 : base_type( first, last, comp, pred, a )
|
Chris@16
|
104 { }
|
Chris@16
|
105
|
Chris@16
|
106 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_set,
|
Chris@16
|
107 base_type,
|
Chris@16
|
108 this_type )
|
Chris@16
|
109
|
Chris@16
|
110 BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_unordered_set,
|
Chris@16
|
111 base_type )
|
Chris@16
|
112
|
Chris@16
|
113 };
|
Chris@16
|
114
|
Chris@16
|
115
|
Chris@16
|
116 template
|
Chris@16
|
117 <
|
Chris@16
|
118 class Key,
|
Chris@16
|
119 class Hash = boost::hash<Key>,
|
Chris@16
|
120 class Pred = std::equal_to<Key>,
|
Chris@16
|
121 class CloneAllocator = heap_clone_allocator,
|
Chris@16
|
122 class Allocator = std::allocator<void*>
|
Chris@16
|
123 >
|
Chris@16
|
124 class ptr_unordered_multiset :
|
Chris@16
|
125 public ptr_multiset_adapter< Key,
|
Chris@16
|
126 boost::unordered_multiset<void*,void_ptr_indirect_fun<Hash,Key>,
|
Chris@16
|
127 void_ptr_indirect_fun<Pred,Key>,Allocator>,
|
Chris@16
|
128 CloneAllocator, false >
|
Chris@16
|
129 {
|
Chris@16
|
130 typedef ptr_multiset_adapter< Key,
|
Chris@16
|
131 boost::unordered_multiset<void*,void_ptr_indirect_fun<Hash,Key>,
|
Chris@16
|
132 void_ptr_indirect_fun<Pred,Key>,Allocator>,
|
Chris@16
|
133 CloneAllocator, false >
|
Chris@16
|
134 base_type;
|
Chris@16
|
135 typedef ptr_unordered_multiset<Key,Hash,Pred,CloneAllocator,Allocator> this_type;
|
Chris@16
|
136
|
Chris@16
|
137 public:
|
Chris@16
|
138 typedef typename base_type::size_type size_type;
|
Chris@16
|
139
|
Chris@16
|
140 private:
|
Chris@16
|
141 using base_type::lower_bound;
|
Chris@16
|
142 using base_type::upper_bound;
|
Chris@16
|
143 using base_type::rbegin;
|
Chris@16
|
144 using base_type::rend;
|
Chris@16
|
145 using base_type::crbegin;
|
Chris@16
|
146 using base_type::crend;
|
Chris@16
|
147 using base_type::key_comp;
|
Chris@16
|
148 using base_type::value_comp;
|
Chris@16
|
149 using base_type::front;
|
Chris@16
|
150 using base_type::back;
|
Chris@16
|
151
|
Chris@16
|
152 public:
|
Chris@16
|
153 using base_type::begin;
|
Chris@16
|
154 using base_type::end;
|
Chris@16
|
155 using base_type::cbegin;
|
Chris@16
|
156 using base_type::cend;
|
Chris@16
|
157 using base_type::bucket_count;
|
Chris@16
|
158 using base_type::max_bucket_count;
|
Chris@16
|
159 using base_type::bucket_size;
|
Chris@16
|
160 using base_type::bucket;
|
Chris@16
|
161 using base_type::load_factor;
|
Chris@16
|
162 using base_type::max_load_factor;
|
Chris@16
|
163 using base_type::rehash;
|
Chris@16
|
164 using base_type::key_eq;
|
Chris@16
|
165 using base_type::hash_function;
|
Chris@16
|
166
|
Chris@16
|
167 public:
|
Chris@16
|
168 ptr_unordered_multiset()
|
Chris@16
|
169 { }
|
Chris@16
|
170
|
Chris@16
|
171 explicit ptr_unordered_multiset( size_type n )
|
Chris@16
|
172 : base_type( n, ptr_container_detail::unordered_associative_container_tag() )
|
Chris@16
|
173 { }
|
Chris@16
|
174
|
Chris@16
|
175 ptr_unordered_multiset( size_type n,
|
Chris@16
|
176 const Hash& comp,
|
Chris@16
|
177 const Pred& pred = Pred(),
|
Chris@16
|
178 const Allocator& a = Allocator() )
|
Chris@16
|
179 : base_type( n, comp, pred, a )
|
Chris@16
|
180 { }
|
Chris@16
|
181
|
Chris@16
|
182 template< typename InputIterator >
|
Chris@16
|
183 ptr_unordered_multiset( InputIterator first, InputIterator last )
|
Chris@16
|
184 : base_type( first, last )
|
Chris@16
|
185 { }
|
Chris@16
|
186
|
Chris@16
|
187 template< typename InputIterator >
|
Chris@16
|
188 ptr_unordered_multiset( InputIterator first, InputIterator last,
|
Chris@16
|
189 const Hash& comp,
|
Chris@16
|
190 const Pred& pred = Pred(),
|
Chris@16
|
191 const Allocator& a = Allocator() )
|
Chris@16
|
192 : base_type( first, last, comp, pred, a )
|
Chris@16
|
193 { }
|
Chris@16
|
194
|
Chris@16
|
195 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_multiset,
|
Chris@16
|
196 base_type,
|
Chris@16
|
197 this_type )
|
Chris@16
|
198
|
Chris@16
|
199 BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_unordered_multiset,
|
Chris@16
|
200 base_type )
|
Chris@16
|
201
|
Chris@16
|
202 };
|
Chris@16
|
203
|
Chris@16
|
204 /////////////////////////////////////////////////////////////////////////
|
Chris@16
|
205 // clonability
|
Chris@16
|
206
|
Chris@16
|
207 template< typename K, typename H, typename P, typename CA, typename A >
|
Chris@16
|
208 inline ptr_unordered_set<K,H,P,CA,A>*
|
Chris@16
|
209 new_clone( const ptr_unordered_set<K,H,P,CA,A>& r )
|
Chris@16
|
210 {
|
Chris@16
|
211 return r.clone().release();
|
Chris@16
|
212 }
|
Chris@16
|
213
|
Chris@16
|
214 template< typename K, typename H, typename P, typename CA, typename A >
|
Chris@16
|
215 inline ptr_unordered_multiset<K,H,P,CA,A>*
|
Chris@16
|
216 new_clone( const ptr_unordered_multiset<K,H,P,CA,A>& r )
|
Chris@16
|
217 {
|
Chris@16
|
218 return r.clone().release();
|
Chris@16
|
219 }
|
Chris@16
|
220
|
Chris@16
|
221 /////////////////////////////////////////////////////////////////////////
|
Chris@16
|
222 // swap
|
Chris@16
|
223
|
Chris@16
|
224 template< typename K, typename H, typename P, typename CA, typename A >
|
Chris@16
|
225 inline void swap( ptr_unordered_set<K,H,P,CA,A>& l,
|
Chris@16
|
226 ptr_unordered_set<K,H,P,CA,A>& r )
|
Chris@16
|
227 {
|
Chris@16
|
228 l.swap(r);
|
Chris@16
|
229 }
|
Chris@16
|
230
|
Chris@16
|
231 template< typename K, typename H, typename P, typename CA, typename A >
|
Chris@16
|
232 inline void swap( ptr_unordered_multiset<K,H,P,CA,A>& l,
|
Chris@16
|
233 ptr_unordered_multiset<K,H,P,CA,A>& r )
|
Chris@16
|
234 {
|
Chris@16
|
235 l.swap(r);
|
Chris@16
|
236 }
|
Chris@16
|
237
|
Chris@16
|
238 }
|
Chris@16
|
239
|
Chris@16
|
240 #endif
|