41 #ifndef PB_DS_HASH_POLICY_HPP
42 #define PB_DS_HASH_POLICY_HPP
44 #include <bits/c++config.h>
56 #define PB_DS_CLASS_T_DEC template<typename Size_Type>
57 #define PB_DS_CLASS_C_DEC linear_probe_fn<Size_Type>
60 template<
typename Size_Type = std::
size_t>
77 #undef PB_DS_CLASS_T_DEC
78 #undef PB_DS_CLASS_C_DEC
80 #define PB_DS_CLASS_T_DEC template<typename Size_Type>
81 #define PB_DS_CLASS_C_DEC quadratic_probe_fn<Size_Type>
84 template<
typename Size_Type = std::
size_t>
101 #undef PB_DS_CLASS_T_DEC
102 #undef PB_DS_CLASS_C_DEC
104 #define PB_DS_CLASS_T_DEC template<typename Size_Type>
105 #define PB_DS_CLASS_C_DEC direct_mask_range_hashing<Size_Type>
108 template<
typename Size_Type = std::
size_t>
133 #undef PB_DS_CLASS_T_DEC
134 #undef PB_DS_CLASS_C_DEC
136 #define PB_DS_CLASS_T_DEC template<typename Size_Type>
137 #define PB_DS_CLASS_C_DEC direct_mod_range_hashing<Size_Type>
140 template<
typename Size_Type = std::
size_t>
165 #undef PB_DS_CLASS_T_DEC
166 #undef PB_DS_CLASS_C_DEC
168 #define PB_DS_CLASS_T_DEC template<bool External_Load_Access, typename Size_Type>
169 #define PB_DS_CLASS_C_DEC hash_load_check_resize_trigger<External_Load_Access, Size_Type>
170 #define PB_DS_SIZE_BASE_C_DEC detail::hash_load_check_resize_trigger_size_base<Size_Type, External_Load_Access>
174 template<
bool External_Load_Access = false,
typename Size_Type = std::
size_t>
192 float load_max = 0.5);
201 inline std::pair<float, float>
207 set_loads(std::pair<float, float> load_pair);
269 #ifdef _GLIBCXX_DEBUG
271 assert_valid(
const char* file,
int line)
const;
283 #undef PB_DS_CLASS_T_DEC
284 #undef PB_DS_CLASS_C_DEC
285 #undef PB_DS_SIZE_BASE_C_DEC
287 #define PB_DS_CLASS_T_DEC template<bool External_Load_Access, typename Size_Type>
288 #define PB_DS_CLASS_C_DEC cc_hash_max_collision_check_resize_trigger<External_Load_Access, Size_Type>
292 template<
bool External_Load_Access = false,
typename Size_Type = std::
size_t>
404 #undef PB_DS_CLASS_T_DEC
405 #undef PB_DS_CLASS_C_DEC
407 #define PB_DS_CLASS_T_DEC template<typename Size_Type>
408 #define PB_DS_CLASS_C_DEC hash_exponential_size_policy<Size_Type>
412 template<
typename Size_Type = std::
size_t>
442 #undef PB_DS_CLASS_T_DEC
443 #undef PB_DS_CLASS_C_DEC
445 #define PB_DS_CLASS_T_DEC
446 #define PB_DS_CLASS_C_DEC hash_prime_size_policy
477 #undef PB_DS_CLASS_T_DEC
478 #undef PB_DS_CLASS_C_DEC
480 #define PB_DS_CLASS_T_DEC template<typename Size_Policy, typename Trigger_Policy, bool External_Size_Access, typename Size_Type>
482 #define PB_DS_CLASS_C_DEC hash_standard_resize_policy<Size_Policy, Trigger_Policy, External_Size_Access, Size_Type>
485 template<
typename Size_Policy = hash_exponential_size_policy<>,
486 typename Trigger_Policy = hash_load_check_re
size_trigger<>,
487 bool External_Size_Access = false,
488 typename Size_Type = std::
size_t>
490 :
public Size_Policy,
public Trigger_Policy
514 const Trigger_Policy& r_trigger_policy);
535 const Trigger_Policy&
612 #undef PB_DS_CLASS_T_DEC
613 #undef PB_DS_CLASS_C_DEC
void notify_erase_search_start()
Notifies an erase search started.
void swap(PB_DS_CLASS_C_DEC &other)
Size_Type size_type
Definition: hash_policy.hpp:296
virtual ~hash_load_check_resize_trigger()
void notify_erased(size_type num_e)
void notify_insert_search_start()
void notify_insert_search_end()
Notifies a search ended.
void swap(PB_DS_CLASS_C_DEC &other)
Definition: hash_policy.hpp:413
void notify_insert_search_start()
Notifies an insert search started.
void notify_find_search_end()
virtual void do_resize(size_type new_size)
Resizes to new_size.
void notify_erase_search_collision()
Notifies a search encountered a collision.
void notify_erase_search_collision()
void swap(PB_DS_CLASS_C_DEC &other)
void notify_externally_resized(size_type new_size)
Notifies the table was resized externally.
void notify_erase_search_end()
size_type m_size
Definition: hash_policy.hpp:607
void notify_resized(size_type new_size)
Size_Type size_type
Definition: mask_based_range_hashing.hpp:53
size_type m_size
Definition: hash_policy.hpp:396
void notify_resized(size_type new_size)
detail::mod_based_range_hashing< size_type > mod_based_base
Definition: hash_policy.hpp:160
Definition: hash_policy.hpp:175
bool is_grow_needed(size_type size, size_type num_entries) const
Trigger_Policy & get_trigger_policy()
Access to the Trigger_Policy object used.
void notify_cleared()
Notifies the table was cleared.
A resize policy which delegates operations to size and trigger policies.
Definition: hash_policy.hpp:489
void resize(size_type suggested_new_size)
Size_Type size_type
Definition: hash_policy.hpp:88
void notify_erase_search_end()
hash_standard_resize_policy()
Default constructor.
size_type m_next_grow_size
Definition: hash_policy.hpp:277
void notify_find_search_start()
Notifies a find search started.
void set_loads(std::pair< float, float > load_pair)
void notify_erased(size_type num_entries)
Notifies an element was erased.
void notify_find_search_collision()
Notifies a search encountered a collision.
Size_Policy & get_size_policy()
Access to the Size_Policy object used.
cc_hash_max_collision_check_resize_trigger(float load=0.5)
void notify_insert_search_collision()
float m_load_min
Definition: hash_policy.hpp:274
A mask range-hashing class (uses a bitmask).
Definition: hash_policy.hpp:109
void swap(PB_DS_CLASS_C_DEC &other)
size_type get_nearest_smaller_size(size_type size) const
void notify_inserted(size_type num_entries)
void notify_externally_resized(size_type new_size)
void notify_erase_search_start()
void notify_resized(size_type new_size)
void swap(PB_DS_CLASS_C_DEC &other)
float get_load() const
Returns the current load.
detail::mask_based_range_hashing< Size_Type > mask_based_base
Definition: hash_policy.hpp:113
void notify_find_search_end()
Notifies a search ended.
Size_Type size_type
Definition: mod_based_range_hashing.hpp:53
void set_load(float load)
Sets the load; does not resize the container.
void calc_resize_needed()
Definition: hash_policy.hpp:303
size_type m_num_col
Definition: hash_policy.hpp:397
void swap(PB_DS_CLASS_C_DEC &other)
virtual void do_resize(size_type new_size)
void swap(PB_DS_CLASS_C_DEC &other)
bool is_grow_needed(size_type size, size_type num_entries) const
Size_Policy size_policy_base
Definition: hash_policy.hpp:605
void notify_insert_search_end()
size_type m_next_shrink_size
Definition: hash_policy.hpp:276
Size_Type size_type
Definition: hash_policy.hpp:178
Trigger_Policy trigger_policy_base
Definition: hash_policy.hpp:603
void notify_find_search_collision()
Size_Type size_type
Definition: hash_policy.hpp:116
size_type m_start_size
Definition: hash_policy.hpp:436
void notify_find_search_collision()
Mod based range hashing.
Definition: mod_based_range_hashing.hpp:50
void notify_cleared()
Notifies the table was cleared.
Size_Type size_type
Definition: hash_policy.hpp:416
hash_load_check_resize_trigger(float load_min=0.125, float load_max=0.5)
hash_prime_size_policy(size_type start_size=8)
Size_Type size_type
Definition: hash_policy.hpp:493
bool m_resize_needed
Definition: hash_policy.hpp:399
void notify_resized(size_type size)
Definition: hash_policy.hpp:185
Definition: hash_policy.hpp:499
__SIZE_TYPE__ size_t
Definition: stddef.h:212
Range hashing policy.
Definition: mask_based_range_hashing.hpp:50
void swap(hash_load_check_resize_trigger &other)
void notify_insert_search_collision()
Notifies a search encountered a collision.
void notify_insert_search_collision()
void notify_find_search_start()
float m_load_max
Definition: hash_policy.hpp:275
Size_Policy size_policy
Definition: hash_policy.hpp:495
A probe sequence policy using square increments.
Definition: hash_policy.hpp:85
size_type get_nearest_larger_size(size_type size) const
Definition: hash_policy.hpp:450
void notify_insert_search_start()
Size_Type size_type
Definition: hash_policy.hpp:64
void swap(PB_DS_CLASS_C_DEC &other)
std::pair< float, float > get_loads() const
Returns a pair of the minimal and maximal loads, respectively.
void notify_resized(size_type size)
size_type get_new_size(size_type size, size_type num_used_e) const
void notify_find_search_end()
A mod range-hashing class (uses the modulo function).
Definition: hash_policy.hpp:141
Definition: hash_policy.hpp:293
bool is_resize_needed() const
size_type operator()(size_type hash) const
bool is_resize_needed() const
hash_exponential_size_policy(size_type start_size=8, size_type grow_factor=2)
size_type operator()(size_type i) const
Returns the i-th offset from the hash value.
Size_Type size_type
Definition: hash_policy.hpp:145
size_type m_start_size
Definition: hash_policy.hpp:472
float m_load
Definition: hash_policy.hpp:395
#define PB_DS_SIZE_BASE_C_DEC
Definition: hash_policy.hpp:170
void notify_find_search_start()
size_type operator()(size_type i) const
Returns the i-th offset from the hash value.
void notify_erase_search_collision()
virtual ~hash_standard_resize_policy()
void notify_inserted(size_type num_entries)
Notifies an element was inserted.
void notify_erase_search_start()
size_type m_grow_factor
Definition: hash_policy.hpp:437
Trigger_Policy trigger_policy
Definition: hash_policy.hpp:494
size_type m_max_col
Definition: hash_policy.hpp:398
#define PB_DS_CLASS_C_DEC
Definition: hash_policy.hpp:482
bool m_resize_needed
Definition: hash_policy.hpp:278
PB_DS_SIZE_BASE_C_DEC size_base
Definition: hash_policy.hpp:267
size_type operator()(size_type hash) const
A probe sequence policy using fixed increments.
Definition: hash_policy.hpp:61
void notify_inserted(size_type num_e)
void notify_insert_search_end()
size_type get_nearest_smaller_size(size_type size) const
void notify_erase_search_end()
Notifies a search ended.
size_type get_nearest_larger_size(size_type size) const
bool is_resize_needed() const
Queries whether a resize is needed.
std::size_t size_type
Size type.
Definition: hash_policy.hpp:454
void notify_erased(size_type num_entries)
size_type get_actual_size() const
Returns the actual size of the container.