42 inline typename PB_DS_CLASS_C_DEC::point_iterator
44 push(const_reference r_val)
47 insert_value(r_val, s_no_throw_copies_ind);
50 return point_iterator(m_a_entries);
58 resize_for_insert_if_needed();
59 m_a_entries[m_size++] = val;
65 insert_value(const_reference r_val,
false_type)
67 resize_for_insert_if_needed();
68 pointer p_new = s_value_allocator.allocate(1);
69 cond_dealtor_t cond(p_new);
70 new (p_new) value_type(r_val);
72 m_a_entries[m_size++] = p_new;
78 resize_for_insert_if_needed()
80 if (!resize_policy::resize_needed_for_grow(m_size))
86 const size_type new_size = resize_policy::get_new_size_for_grow();
87 entry_pointer new_entries = s_entry_allocator.allocate(new_size);
88 resize_policy::notify_grow_resize();
90 std::copy(m_a_entries, m_a_entries + m_size, new_entries);
91 s_entry_allocator.deallocate(m_a_entries, m_actual_size);
92 m_actual_size = new_size;
93 m_a_entries = new_entries;
100 modify(point_iterator it, const_reference r_new_val)
103 swap_value_imp(it.m_p_e, r_new_val, s_no_throw_copies_ind);
112 fix(entry_pointer p_e)
114 size_type i = p_e - m_a_entries;
115 if (i > 0 && entry_cmp::operator()(m_a_entries[parent(i)], m_a_entries[i]))
117 size_type parent_i = parent(i);
119 && entry_cmp::operator()(m_a_entries[parent_i], m_a_entries[i]))
121 std::swap(m_a_entries[i], m_a_entries[parent_i]);
123 parent_i = parent(i);
132 const size_type lchild_i = left_child(i);
133 const size_type rchild_i = right_child(i);
136 const bool smaller_than_lchild = lchild_i < m_size &&
137 entry_cmp::operator()(m_a_entries[i], m_a_entries[lchild_i]);
139 const bool smaller_than_rchild = rchild_i < m_size &&
140 entry_cmp::operator()(m_a_entries[i], m_a_entries[rchild_i]);
142 const bool swap_with_rchild = smaller_than_rchild && (!smaller_than_lchild || entry_cmp::operator()(m_a_entries[lchild_i], m_a_entries[rchild_i]));
144 const bool swap_with_lchild = !swap_with_rchild && smaller_than_lchild;
146 if (swap_with_lchild)
148 std::swap(m_a_entries[i], m_a_entries[lchild_i]);
151 else if (swap_with_rchild)
153 std::swap(m_a_entries[i], m_a_entries[rchild_i]);
164 swap_value_imp(entry_pointer p_e, value_type new_val,
true_type)
170 swap_value_imp(entry_pointer p_e, const_reference r_new_val,
false_type)
172 value_type tmp(r_new_val);
#define _GLIBCXX_DEBUG_ASSERT(_Condition)
Definition: debug.h:61
#define PB_DS_CLASS_C_DEC
Definition: bin_search_tree_.hpp:71
#define PB_DS_CLASS_T_DEC
Definition: bin_search_tree_.hpp:67
return(unsigned int) __res
std::tr1::integral_constant< int, 1 > true_type
Definition: type_utils.hpp:70
#define PB_DS_ASSERT_VALID(X)
Definition: binary_heap_.hpp:324
void swap(exception_ptr &__lhs, exception_ptr &__rhs)
Definition: exception_ptr.h:160
std::tr1::integral_constant< int, 0 > false_type
Definition: type_utils.hpp:71