42 #ifndef PB_DS_DEBUG_MAP_BASE_HPP
43 #define PB_DS_DEBUG_MAP_BASE_HPP
59 template<
typename _CharT,
typename _Traits,
typename _Tp1,
typename _Tp2>
61 operator<<(std::basic_ostream<_CharT, _Traits>& __out,
63 {
return (__out <<
'(' << p.first <<
',' << p.second <<
')'); }
65 #define PB_DS_CLASS_T_DEC \
66 template<typename Key, class Eq_Fn, typename Const_Key_Reference>
68 #define PB_DS_CLASS_C_DEC \
69 debug_map_base<Key, Eq_Fn, Const_Key_Reference>
71 template<
typename Key,
class Eq_Fn,
typename Const_Key_Reference>
76 typedef typename key_allocator::size_type size_type;
77 typedef Const_Key_Reference const_key_reference;
78 typedef std::_GLIBCXX_STD_C::list<Key> key_set;
79 typedef typename key_set::iterator key_set_iterator;
80 typedef typename key_set::const_iterator const_key_set_iterator;
82 typedef typename key_db_allocator::never_adjustor never_adjustor;
87 debug_map_base(
const PB_DS_CLASS_C_DEC& other);
92 insert_new(const_key_reference r_key);
95 erase_existing(const_key_reference r_key);
101 check_key_exists(const_key_reference r_key)
const;
104 check_key_does_not_exist(const_key_reference r_key)
const;
107 check_size(size_type
size)
const;
110 swap(PB_DS_CLASS_C_DEC& other);
112 template<
typename Cmp_Fn>
114 split(const_key_reference, Cmp_Fn, PB_DS_CLASS_C_DEC&);
117 join(PB_DS_CLASS_C_DEC& other);
121 assert_valid()
const;
123 const_key_set_iterator
124 find(const_key_reference r_key)
const;
127 find(const_key_reference r_key);
136 { _GLIBCXX_DEBUG_ONLY(assert_valid();) }
140 debug_map_base(
const PB_DS_CLASS_C_DEC& other) : m_key_set(other.m_key_set)
141 { _GLIBCXX_DEBUG_ONLY(assert_valid();) }
146 { _GLIBCXX_DEBUG_ONLY(assert_valid();) }
151 insert_new(const_key_reference r_key)
153 _GLIBCXX_DEBUG_ONLY(assert_valid();)
155 if (find(r_key) != m_key_set.end())
161 never_adjustor never;
164 m_key_set.push_back(r_key);
172 _GLIBCXX_DEBUG_ONLY(assert_valid();)
178 erase_existing(const_key_reference r_key)
180 _GLIBCXX_DEBUG_ONLY(assert_valid();)
181 key_set_iterator it = find(r_key);
182 if (it == m_key_set.end())
188 _GLIBCXX_DEBUG_ONLY(assert_valid();)
196 _GLIBCXX_DEBUG_ONLY(assert_valid();)
198 _GLIBCXX_DEBUG_ONLY(assert_valid();)
204 check_key_exists(const_key_reference r_key)
const
206 _GLIBCXX_DEBUG_ONLY(assert_valid();)
207 if (find(r_key) == m_key_set.end())
212 _GLIBCXX_DEBUG_ONLY(assert_valid();)
218 check_key_does_not_exist(const_key_reference r_key)
const
220 _GLIBCXX_DEBUG_ONLY(assert_valid();)
221 if (find(r_key) != m_key_set.end())
225 cerr <<
"check_key_does_not_exist " << r_key <<
endl;
233 check_size(size_type
size)
const
235 _GLIBCXX_DEBUG_ONLY(assert_valid();)
236 const size_type key_set_size = m_key_set.size();
237 if (size != key_set_size)
243 _GLIBCXX_DEBUG_ONLY(assert_valid();)
249 swap(PB_DS_CLASS_C_DEC& other)
251 _GLIBCXX_DEBUG_ONLY(assert_valid();)
252 m_key_set.swap(other.m_key_set);
253 _GLIBCXX_DEBUG_ONLY(assert_valid();)
257 typename PB_DS_CLASS_C_DEC::const_key_set_iterator
259 find(const_key_reference r_key)
const
261 _GLIBCXX_DEBUG_ONLY(assert_valid();)
262 typedef const_key_set_iterator iterator_type;
263 for (iterator_type it = m_key_set.begin(); it != m_key_set.end(); ++it)
264 if (m_eq(*it, r_key))
266 return m_key_set.end();
270 typename PB_DS_CLASS_C_DEC::key_set_iterator
272 find(const_key_reference r_key)
274 _GLIBCXX_DEBUG_ONLY(assert_valid();)
275 key_set_iterator it = m_key_set.begin();
276 while (it != m_key_set.end())
278 if (m_eq(*it, r_key))
283 _GLIBCXX_DEBUG_ONLY(assert_valid();)
291 const_key_set_iterator prime_it = m_key_set.begin();
292 while (prime_it != m_key_set.end())
294 const_key_set_iterator sec_it = prime_it;
296 while (sec_it != m_key_set.end())
298 _GLIBCXX_DEBUG_ASSERT(!m_eq(*sec_it, *prime_it));
299 _GLIBCXX_DEBUG_ASSERT(!m_eq(*prime_it, *sec_it));
307 template<
typename Cmp_Fn>
310 split(const_key_reference r_key, Cmp_Fn cmp_fn, PB_DS_CLASS_C_DEC& other)
313 key_set_iterator it = m_key_set.begin();
314 while (it != m_key_set.end())
315 if (cmp_fn(r_key, * it))
317 other.insert_new(*it);
318 it = m_key_set.erase(it);
327 join(PB_DS_CLASS_C_DEC& other)
329 key_set_iterator it = other.m_key_set.begin();
330 while (it != other.m_key_set.end())
333 it = other.m_key_set.erase(it);
335 _GLIBCXX_DEBUG_ASSERT(other.m_key_set.empty());
338 #undef PB_DS_CLASS_T_DEC
339 #undef PB_DS_CLASS_C_DEC
Struct holding two objects of arbitrary type.
Controlling output.This is the base class for all output streams. It provides text formatting of all ...
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
Write a newline and flush the stream.
Allocator throwing via random condition.
ostream cerr
Linked to standard output.
constexpr size_t size() const
Returns the total number of bits.
The standard allocator, as per [20.4].Further details: http://gcc.gnu.org/onlinedocs/libstdc++/manual...