41 #ifndef PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP
42 #define PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP
51 template<
typename _Tp>
112 #ifdef _GLIBCXX_DEBUG
114 assert_valid(
const char*,
int)
const;
117 #ifdef PB_DS_BINARY_HEAP_TRACE_
123 template<
typename _Tp>
124 const _Tp resize_policy<_Tp>::min_size;
126 template<
typename _Tp>
135 template<
typename _Tp>
141 return size == m_grow_size;
144 template<
typename _Tp>
150 return size == m_shrink_size;
153 template<
typename _Tp>
157 {
return m_grow_size * factor; }
159 template<
typename _Tp>
164 const size_type half_size = m_grow_size / factor;
165 return std::max(min_size, half_size);
168 template<
typename _Tp>
179 template<
typename _Tp>
186 m_grow_size *= factor;
187 m_shrink_size = m_grow_size / ratio;
191 template<
typename _Tp>
197 m_shrink_size /= factor;
198 if (m_shrink_size == 1)
200 m_grow_size =
std::max(m_grow_size / factor, min_size);
204 template<
typename _Tp>
209 m_grow_size = actual_size;
210 m_shrink_size = m_grow_size / ratio;
214 #ifdef _GLIBCXX_DEBUG
215 template<
typename _Tp>
221 || m_shrink_size * ratio == m_grow_size);
226 #ifdef PB_DS_BINARY_HEAP_TRACE_
227 template<
typename _Tp>
232 std::cerr <<
"shrink = " << m_shrink_size
233 <<
" grow = " << m_grow_size << std::endl;
Definition: resize_policy.hpp:57
_Tp m_grow_size
Next grow size.
Definition: resize_policy.hpp:65
void swap(resize_policy< _Tp > &)
Definition: resize_policy.hpp:129
size_type get_new_size_for_grow() const
Definition: resize_policy.hpp:156
#define _GLIBCXX_DEBUG_ASSERT(_Condition)
Definition: debug.h:61
Definition: resize_policy.hpp:58
void notify_grow_resize()
Definition: resize_policy.hpp:182
bool resize_needed_for_shrink(size_type) const
Definition: resize_policy.hpp:147
resize_policy(const resize_policy &other)
Definition: resize_policy.hpp:75
size_type get_new_size_for_shrink() const
Definition: resize_policy.hpp:162
size_type get_new_size_for_arbitrary(size_type) const
Definition: resize_policy.hpp:171
static const _Tp min_size
Definition: resize_policy.hpp:70
void notify_shrink_resize()
Definition: resize_policy.hpp:194
Resize policy for binary heap.
Definition: resize_policy.hpp:52
const _Tp & max(const _Tp &__a, const _Tp &__b)
Equivalent to std::max.
Definition: base.h:150
resize_policy()
Definition: resize_policy.hpp:72
bool grow_needed(size_type) const
#define PB_DS_ASSERT_VALID(X)
Definition: binary_heap_.hpp:324
_Tp size_type
Definition: resize_policy.hpp:68
_Tp m_shrink_size
Next shrink size.
Definition: resize_policy.hpp:62
#define PB_DS_DEBUG_VERIFY(_Cond)
Definition: binary_heap_.hpp:327
void notify_arbitrary(size_type)
Definition: resize_policy.hpp:207
bool shrink_needed(size_type) const
void swap(exception_ptr &__lhs, exception_ptr &__rhs)
Definition: exception_ptr.h:160
bool resize_needed_for_grow(size_type) const
Definition: resize_policy.hpp:138