41 #ifdef PB_DS_CLASS_C_DEC
48 assert_valid(
const char* __file,
int __line)
const
50 structure_only_assert_valid(__file, __line);
51 assert_consistent_with_debug_base(__file, __line);
52 assert_size(__file, __line);
53 assert_iterators(__file, __line);
54 if (m_p_head->m_p_parent == 0)
56 PB_DS_DEBUG_VERIFY(m_size == 0);
60 PB_DS_DEBUG_VERIFY(m_size > 0);
67 structure_only_assert_valid(
const char* __file,
int __line)
const
69 PB_DS_DEBUG_VERIFY(m_p_head != 0);
70 if (m_p_head->m_p_parent == 0)
72 PB_DS_DEBUG_VERIFY(m_p_head->m_p_left == m_p_head);
73 PB_DS_DEBUG_VERIFY(m_p_head->m_p_right == m_p_head);
77 PB_DS_DEBUG_VERIFY(m_p_head->m_p_parent->m_p_parent == m_p_head);
78 PB_DS_DEBUG_VERIFY(m_p_head->m_p_left != m_p_head);
79 PB_DS_DEBUG_VERIFY(m_p_head->m_p_right != m_p_head);
82 if (m_p_head->m_p_parent != 0)
83 assert_node_consistent(m_p_head->m_p_parent, __file, __line);
84 assert_min(__file, __line);
85 assert_max(__file, __line);
91 assert_node_consistent(
const node_pointer p_nd,
92 const char* __file,
int __line)
const
94 assert_node_consistent_(p_nd, __file, __line);
98 typename PB_DS_CLASS_C_DEC::node_consistent_t
100 assert_node_consistent_(
const node_pointer p_nd,
101 const char* __file,
int __line)
const
104 return (std::make_pair((const_pointer)0,(const_pointer)0));
106 assert_node_consistent_with_left(p_nd, __file, __line);
107 assert_node_consistent_with_right(p_nd, __file, __line);
110 l_range = assert_node_consistent_(p_nd->m_p_left, __file, __line);
113 PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*l_range.
second),
114 PB_DS_V2F(p_nd->m_value)));
117 r_range = assert_node_consistent_(p_nd->m_p_right, __file, __line);
119 if (r_range.
first != 0)
120 PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
121 PB_DS_V2F(*r_range.
first)));
123 return std::make_pair((l_range.
first != 0) ? l_range.
first : &p_nd->m_value,
124 (r_range.
second != 0)? r_range.
second : &p_nd->m_value);
130 assert_node_consistent_with_left(
const node_pointer p_nd,
131 const char* __file,
int __line)
const
133 if (p_nd->m_p_left == 0)
135 PB_DS_DEBUG_VERIFY(p_nd->m_p_left->m_p_parent == p_nd);
136 PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
137 PB_DS_V2F(p_nd->m_p_left->m_value)));
143 assert_node_consistent_with_right(
const node_pointer p_nd,
144 const char* __file,
int __line)
const
146 if (p_nd->m_p_right == 0)
148 PB_DS_DEBUG_VERIFY(p_nd->m_p_right->m_p_parent == p_nd);
149 PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_p_right->m_value),
150 PB_DS_V2F(p_nd->m_value)));
156 assert_min(
const char* __file,
int __line)
const
158 assert_min_imp(m_p_head->m_p_parent, __file, __line);
164 assert_min_imp(
const node_pointer p_nd,
const char* __file,
int __line)
const
168 PB_DS_DEBUG_VERIFY(m_p_head->m_p_left == m_p_head);
172 if (p_nd->m_p_left == 0)
174 PB_DS_DEBUG_VERIFY(p_nd == m_p_head->m_p_left);
177 assert_min_imp(p_nd->m_p_left, __file, __line);
183 assert_max(
const char* __file,
int __line)
const
185 assert_max_imp(m_p_head->m_p_parent, __file, __line);
191 assert_max_imp(
const node_pointer p_nd,
192 const char* __file,
int __line)
const
196 PB_DS_DEBUG_VERIFY(m_p_head->m_p_right == m_p_head);
200 if (p_nd->m_p_right == 0)
202 PB_DS_DEBUG_VERIFY(p_nd == m_p_head->m_p_right);
206 assert_max_imp(p_nd->m_p_right, __file, __line);
212 assert_iterators(
const char* __file,
int __line)
const
214 size_type iterated_num = 0;
215 const_iterator prev_it =
end();
216 for (const_iterator it =
begin(); it !=
end(); ++it)
219 PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)).m_p_nd == it.m_p_nd);
220 const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it));
222 PB_DS_DEBUG_VERIFY(upper_bound_it.m_p_nd == it.m_p_nd);
224 if (prev_it !=
end())
225 PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*prev_it),
230 PB_DS_DEBUG_VERIFY(iterated_num == m_size);
231 size_type reverse_iterated_num = 0;
232 const_reverse_iterator reverse_prev_it = rend();
233 for (const_reverse_iterator reverse_it = rbegin(); reverse_it != rend();
236 ++reverse_iterated_num;
237 PB_DS_DEBUG_VERIFY(lower_bound(
238 PB_DS_V2F(*reverse_it)).m_p_nd == reverse_it.m_p_nd);
240 const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*reverse_it));
242 PB_DS_DEBUG_VERIFY(upper_bound_it.m_p_nd == reverse_it.m_p_nd);
243 if (reverse_prev_it != rend())
244 PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(*reverse_prev_it),
245 PB_DS_V2F(*reverse_it)));
246 reverse_prev_it = reverse_it;
248 PB_DS_DEBUG_VERIFY(reverse_iterated_num == m_size);
254 assert_consistent_with_debug_base(
const char* __file,
int __line)
const
256 debug_base::check_size(m_size, __file, __line);
257 assert_consistent_with_debug_base(m_p_head->m_p_parent, __file, __line);
263 assert_consistent_with_debug_base(
const node_pointer p_nd,
264 const char* __file,
int __line)
const
268 debug_base::check_key_exists(PB_DS_V2F(p_nd->m_value), __file, __line);
269 assert_consistent_with_debug_base(p_nd->m_p_left, __file, __line);
270 assert_consistent_with_debug_base(p_nd->m_p_right, __file, __line);
276 assert_size(
const char* __file,
int __line)
const
277 { PB_DS_DEBUG_VERIFY(recursive_count(m_p_head->m_p_parent) == m_size); }
constexpr const _Tp * begin(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to the first element of the initializer_list.
constexpr const _Tp * end(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to one past the last element of the initializer_list.
Struct holding two objects of arbitrary type.
_T1 first
The first member.
_T2 second
The second member.