42 #ifndef PB_DS_RANGED_HASH_FN_HPP
43 #define PB_DS_RANGED_HASH_FN_HPP
54 template<
typename Key,
typename Hash_Fn,
typename _Alloc,
55 typename Comb_Hash_Fn,
bool Store_Hash>
58 #define PB_DS_CLASS_T_DEC \
59 template<typename Key, typename Hash_Fn, typename _Alloc, \
60 typename Comb_Hash_Fn>
62 #define PB_DS_CLASS_C_DEC \
63 ranged_hash_fn<Key, Hash_Fn, _Alloc, Comb_Hash_Fn, false>
70 template<
typename Key,
typename Hash_Fn,
typename _Alloc,
71 typename Comb_Hash_Fn>
73 :
public Hash_Fn,
public Comb_Hash_Fn
76 typedef typename _Alloc::size_type size_type;
77 typedef Hash_Fn hash_fn_base;
78 typedef Comb_Hash_Fn comb_hash_fn_base;
79 typedef typename rebind_traits<_Alloc, Key>::const_reference
89 swap(PB_DS_CLASS_C_DEC&);
92 notify_resized(size_type);
95 operator()(key_const_reference)
const;
100 ranged_hash_fn(size_type size)
101 { Comb_Hash_Fn::notify_resized(size); }
105 ranged_hash_fn(size_type size,
const Hash_Fn& r_hash_fn)
107 { Comb_Hash_Fn::notify_resized(size); }
111 ranged_hash_fn(size_type size,
const Hash_Fn& r_hash_fn,
112 const Comb_Hash_Fn& r_comb_hash_fn)
113 : Hash_Fn(r_hash_fn), Comb_Hash_Fn(r_comb_hash_fn)
114 { comb_hash_fn_base::notify_resized(size); }
119 swap(PB_DS_CLASS_C_DEC& other)
121 comb_hash_fn_base::swap(other);
122 std::swap((Hash_Fn& )(*
this), (Hash_Fn& )other);
128 notify_resized(size_type size)
129 { comb_hash_fn_base::notify_resized(size); }
132 inline typename PB_DS_CLASS_C_DEC::size_type
134 operator()(key_const_reference r_key)
const
135 {
return (comb_hash_fn_base::operator()(hash_fn_base::operator()(r_key)));}
137 #undef PB_DS_CLASS_T_DEC
138 #undef PB_DS_CLASS_C_DEC
140 #define PB_DS_CLASS_T_DEC \
141 template<typename Key, typename Hash_Fn, typename _Alloc, \
142 typename Comb_Hash_Fn>
144 #define PB_DS_CLASS_C_DEC \
145 ranged_hash_fn<Key,Hash_Fn, _Alloc, Comb_Hash_Fn, true>
152 template<
typename Key,
typename Hash_Fn,
typename _Alloc,
153 typename Comb_Hash_Fn>
155 :
public Hash_Fn,
public Comb_Hash_Fn
158 typedef typename _Alloc::size_type size_type;
160 typedef Hash_Fn hash_fn_base;
161 typedef Comb_Hash_Fn comb_hash_fn_base;
162 typedef typename rebind_traits<_Alloc, Key>::const_reference
172 swap(PB_DS_CLASS_C_DEC&);
175 notify_resized(size_type);
178 operator()(key_const_reference)
const;
181 operator()(key_const_reference, size_type)
const;
186 ranged_hash_fn(size_type size)
187 { Comb_Hash_Fn::notify_resized(size); }
191 ranged_hash_fn(size_type size,
const Hash_Fn& r_hash_fn) :
193 { Comb_Hash_Fn::notify_resized(size); }
197 ranged_hash_fn(size_type size,
const Hash_Fn& r_hash_fn,
198 const Comb_Hash_Fn& r_comb_hash_fn)
199 : Hash_Fn(r_hash_fn), Comb_Hash_Fn(r_comb_hash_fn)
200 { comb_hash_fn_base::notify_resized(size); }
205 swap(PB_DS_CLASS_C_DEC& other)
207 comb_hash_fn_base::swap(other);
208 std::swap((Hash_Fn& )(*
this), (Hash_Fn& )other);
214 notify_resized(size_type size)
215 { comb_hash_fn_base::notify_resized(size); }
218 inline typename PB_DS_CLASS_C_DEC::comp_hash
220 operator()(key_const_reference r_key)
const
222 const size_type hash = hash_fn_base::operator()(r_key);
223 return std::make_pair(comb_hash_fn_base::operator()(hash), hash);
227 inline typename PB_DS_CLASS_C_DEC::comp_hash
230 #ifdef _GLIBCXX_DEBUG
231 (key_const_reference r_key, size_type hash)
const
233 (key_const_reference , size_type hash)
const
236 _GLIBCXX_DEBUG_ASSERT(hash == hash_fn_base::operator()(r_key));
237 return std::make_pair(comb_hash_fn_base::operator()(hash), hash);
240 #undef PB_DS_CLASS_T_DEC
241 #undef PB_DS_CLASS_C_DEC
243 #define PB_DS_CLASS_T_DEC \
244 template<typename Key, typename _Alloc, typename Comb_Hash_Fn>
246 #define PB_DS_CLASS_C_DEC \
247 ranged_hash_fn<Key, null_type, _Alloc, Comb_Hash_Fn, false>
255 template<
typename Key,
typename _Alloc,
typename Comb_Hash_Fn>
257 :
public Comb_Hash_Fn
260 typedef typename _Alloc::size_type size_type;
261 typedef Comb_Hash_Fn comb_hash_fn_base;
270 swap(PB_DS_CLASS_C_DEC&);
275 ranged_hash_fn(size_type size)
276 { Comb_Hash_Fn::notify_resized(size); }
280 ranged_hash_fn(size_type size,
const Comb_Hash_Fn& r_comb_hash_fn) :
281 Comb_Hash_Fn(r_comb_hash_fn)
286 ranged_hash_fn(size_type size,
const null_type& r_null_type,
287 const Comb_Hash_Fn& r_comb_hash_fn)
288 : Comb_Hash_Fn(r_comb_hash_fn)
294 swap(PB_DS_CLASS_C_DEC& other)
295 { comb_hash_fn_base::swap(other); }
297 #undef PB_DS_CLASS_T_DEC
298 #undef PB_DS_CLASS_C_DEC
300 #define PB_DS_CLASS_T_DEC \
301 template<typename Key, typename _Alloc, typename Comb_Hash_Fn>
303 #define PB_DS_CLASS_C_DEC \
304 ranged_hash_fn<Key, null_type, _Alloc, Comb_Hash_Fn, true>
312 template<
typename Key,
typename _Alloc,
typename Comb_Hash_Fn>
314 :
public Comb_Hash_Fn
317 typedef typename _Alloc::size_type size_type;
318 typedef Comb_Hash_Fn comb_hash_fn_base;
327 swap(PB_DS_CLASS_C_DEC&);
332 ranged_hash_fn(size_type size)
333 { Comb_Hash_Fn::notify_resized(size); }
337 ranged_hash_fn(size_type size,
const Comb_Hash_Fn& r_comb_hash_fn)
338 : Comb_Hash_Fn(r_comb_hash_fn)
343 ranged_hash_fn(size_type size,
const null_type& r_null_type,
344 const Comb_Hash_Fn& r_comb_hash_fn)
345 : Comb_Hash_Fn(r_comb_hash_fn)
351 swap(PB_DS_CLASS_C_DEC& other)
352 { comb_hash_fn_base::swap(other); }
354 #undef PB_DS_CLASS_T_DEC
355 #undef PB_DS_CLASS_C_DEC
GNU extensions for policy-based data structures for public use.
Struct holding two objects of arbitrary type.
Represents no type, or absence of type, for template tricks.