41 #ifdef PB_DS_CLASS_C_DEC
44 inline typename PB_DS_CLASS_C_DEC::point_iterator
46 push(const_reference r_val)
48 PB_DS_ASSERT_VALID((*
this))
49 insert_value(r_val, s_no_throw_copies_ind);
51 PB_DS_ASSERT_VALID((*this))
52 return point_iterator(m_a_entries);
60 resize_for_insert_if_needed();
61 m_a_entries[m_size++] = val;
67 insert_value(const_reference r_val,
false_type)
69 resize_for_insert_if_needed();
70 pointer p_new = s_value_allocator.allocate(1);
71 cond_dealtor_t cond(p_new);
72 new (p_new) value_type(r_val);
74 m_a_entries[m_size++] = p_new;
80 resize_for_insert_if_needed()
82 if (!resize_policy::resize_needed_for_grow(m_size))
84 _GLIBCXX_DEBUG_ASSERT(m_size < m_actual_size);
88 const size_type new_size = resize_policy::get_new_size_for_grow();
89 entry_pointer new_entries = s_entry_allocator.allocate(new_size);
90 resize_policy::notify_grow_resize();
92 std::copy(m_a_entries, m_a_entries + m_size, new_entries);
93 s_entry_allocator.deallocate(m_a_entries, m_actual_size);
94 m_actual_size = new_size;
95 m_a_entries = new_entries;
102 modify(point_iterator it, const_reference r_new_val)
104 PB_DS_ASSERT_VALID((*
this))
105 swap_value_imp(it.m_p_e, r_new_val, s_no_throw_copies_ind);
107 PB_DS_ASSERT_VALID((*this))
113 fix(entry_pointer p_e)
115 size_type i = p_e - m_a_entries;
116 if (i > 0 && entry_cmp::operator()(m_a_entries[parent(i)], m_a_entries[i]))
118 size_type parent_i = parent(i);
120 && entry_cmp::operator()(m_a_entries[parent_i], m_a_entries[i]))
122 std::swap(m_a_entries[i], m_a_entries[parent_i]);
124 parent_i = parent(i);
127 PB_DS_ASSERT_VALID((*
this))
133 const size_type lchild_i = left_child(i);
134 const size_type rchild_i = right_child(i);
135 _GLIBCXX_DEBUG_ASSERT(rchild_i > lchild_i);
137 const bool smaller_than_lchild = lchild_i < m_size &&
138 entry_cmp::operator()(m_a_entries[i], m_a_entries[lchild_i]);
140 const bool smaller_than_rchild = rchild_i < m_size &&
141 entry_cmp::operator()(m_a_entries[i], m_a_entries[rchild_i]);
143 const bool swap_with_rchild = smaller_than_rchild && (!smaller_than_lchild || entry_cmp::operator()(m_a_entries[lchild_i], m_a_entries[rchild_i]));
145 const bool swap_with_lchild = !swap_with_rchild && smaller_than_lchild;
147 if (swap_with_lchild)
149 std::swap(m_a_entries[i], m_a_entries[lchild_i]);
152 else if (swap_with_rchild)
154 std::swap(m_a_entries[i], m_a_entries[rchild_i]);
165 swap_value_imp(entry_pointer p_e, value_type new_val,
true_type)
171 swap_value_imp(entry_pointer p_e, const_reference r_new_val,
false_type)
173 value_type tmp(r_new_val);
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.