41 #define PB_DS_ASSERT_VALID(X) \
42 _GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
46 hash_load_check_resize_trigger(
float load_min,
float load_max)
47 : m_load_min(load_min), m_load_max(load_max), m_next_shrink_size(0),
48 m_next_grow_size(0), m_resize_needed(
false)
54 notify_find_search_start()
60 notify_find_search_collision()
66 notify_find_search_end()
72 notify_insert_search_start()
78 notify_insert_search_collision()
84 notify_insert_search_end()
90 notify_erase_search_start()
96 notify_erase_search_collision()
102 notify_erase_search_end()
108 notify_inserted(size_type num_entries)
110 m_resize_needed = (num_entries >= m_next_grow_size);
111 size_base::set_size(num_entries);
118 notify_erased(size_type num_entries)
120 size_base::set_size(num_entries);
121 m_resize_needed = num_entries <= m_next_shrink_size;
128 is_resize_needed()
const
137 is_grow_needed(size_type , size_type num_entries)
const
140 return num_entries >= m_next_grow_size;
145 ~hash_load_check_resize_trigger() { }
150 notify_resized(size_type new_size)
152 m_resize_needed =
false;
153 m_next_grow_size = size_type(m_load_max * new_size - 1);
154 m_next_shrink_size = size_type(m_load_min * new_size);
156 #ifdef PB_DS_HT_MAP_RESIZE_TRACE_
157 std::cerr <<
"hlcrt::notify_resized " << std::endl
158 <<
"1 " << new_size << std::endl
159 <<
"2 " << m_load_min << std::endl
160 <<
"3 " << m_load_max << std::endl
161 <<
"4 " << m_next_shrink_size << std::endl
162 <<
"5 " << m_next_grow_size << std::endl;
171 notify_externally_resized(size_type new_size)
173 m_resize_needed =
false;
174 size_type new_grow_size = size_type(m_load_max * new_size - 1);
175 size_type new_shrink_size = size_type(m_load_min * new_size);
177 #ifdef PB_DS_HT_MAP_RESIZE_TRACE_
178 std::cerr <<
"hlcrt::notify_externally_resized " << std::endl
179 <<
"1 " << new_size << std::endl
180 <<
"2 " << m_load_min << std::endl
181 <<
"3 " << m_load_max << std::endl
182 <<
"4 " << m_next_shrink_size << std::endl
183 <<
"5 " << m_next_grow_size << std::endl
184 <<
"6 " << new_shrink_size << std::endl
185 <<
"7 " << new_grow_size << std::endl;
188 if (new_grow_size >= m_next_grow_size)
191 m_next_grow_size = new_grow_size;
196 m_next_shrink_size = new_shrink_size;
208 size_base::set_size(0);
209 m_resize_needed = (0 < m_next_shrink_size);
221 size_base::
swap(other);
222 std::
swap(m_load_min, other.m_load_min);
223 std::
swap(m_load_max, other.m_load_max);
224 std::
swap(m_resize_needed, other.m_resize_needed);
225 std::
swap(m_next_grow_size, other.m_next_grow_size);
226 std::
swap(m_next_shrink_size, other.m_next_shrink_size);
233 inline std::pair<
float,
float>
238 return std::make_pair(m_load_min, m_load_max);
244 set_loads(std::pair<float, float> load_pair)
247 const float old_load_min = m_load_min;
248 const float old_load_max = m_load_max;
249 const size_type old_next_shrink_size = m_next_shrink_size;
250 const size_type old_next_grow_size = m_next_grow_size;
251 const bool old_resize_needed = m_resize_needed;
255 m_load_min = load_pair.first;
256 m_load_max = load_pair.second;
257 do_resize(static_cast<size_type>(size_base::get_size() / ((m_load_min + m_load_max) / 2)));
261 m_load_min = old_load_min;
262 m_load_max = old_load_max;
263 m_next_shrink_size = old_next_shrink_size;
264 m_next_grow_size = old_next_grow_size;
265 m_resize_needed = old_resize_needed;
276 #ifdef _GLIBCXX_DEBUG
277 # define PB_DS_DEBUG_VERIFY(_Cond) \
278 _GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
279 _M_message(#_Cond" assertion from %1;:%2;") \
280 ._M_string(__FILE__)._M_integer(__LINE__) \
286 assert_valid(
const char* __file,
int __line)
const
291 # undef PB_DS_DEBUG_VERIFY
293 #undef PB_DS_ASSERT_VALID
#define false
Definition: stdbool.h:35
#define __try
Definition: exception_defines.h:35
#define _GLIBCXX_DEBUG_ASSERT(_Condition)
Definition: debug.h:61
#define __throw_exception_again
Definition: exception_defines.h:37
#define PB_DS_CLASS_C_DEC
Definition: bin_search_tree_.hpp:71
#define PB_DS_ASSERT_VALID(X)
Definition: hash_load_check_resize_trigger_imp.hpp:41
#define PB_DS_STATIC_ASSERT(UNIQUE, E)
Definition: type_utils.hpp:154
#define PB_DS_CLASS_T_DEC
Definition: bin_search_tree_.hpp:67
return(unsigned int) __res
#define __catch(X)
Definition: exception_defines.h:36
#define PB_DS_DEBUG_VERIFY(_Cond)
Definition: binary_heap_.hpp:327
void swap(exception_ptr &__lhs, exception_ptr &__rhs)
Definition: exception_ptr.h:160