159157Sache// -*- C++ -*- 259157Sache 386799Sache// Copyright (C) 2005-2022 Free Software Foundation, Inc. 486799Sache// 586799Sache// This file is part of the GNU ISO C++ Library. This library is free 686799Sache// software; you can redistribute it and/or modify it under the terms 786799Sache// of the GNU General Public License as published by the Free Software 886799Sache// Foundation; either version 3, or (at your option) any later 986799Sache// version. 1086799Sache 1186799Sache// This library is distributed in the hope that it will be useful, but 1286799Sache// WITHOUT ANY WARRANTY; without even the implied warranty of 1386799Sache// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1486799Sache// General Public License for more details. 1559157Sache 1659157Sache// Under Section 7 of GPL version 3, you are granted additional 1759157Sache// permissions described in the GCC Runtime Library Exception, version 1859157Sache// 3.1, as published by the Free Software Foundation. 1959157Sache 2059157Sache// You should have received a copy of the GNU General Public License and 2159157Sache// a copy of the GCC Runtime Library Exception along with this program; 2259157Sache// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 2359157Sache// <http://www.gnu.org/licenses/>. 2459157Sache 2559157Sache// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. 2659157Sache 2759157Sache// Permission to use, copy, modify, sell, and distribute this software 2859157Sache// is hereby granted without fee, provided that the above copyright 2959157Sache// notice appears in all copies, and that both that copyright notice 3059157Sache// and this permission notice appear in supporting documentation. None 3159157Sache// of the above authors, nor IBM Haifa Research Laboratories, make any 3259157Sache// representation about the suitability of this software for any 3359157Sache// purpose. It is provided "as is" without express or implied 3459157Sache// warranty. 3559157Sache 3659157Sache/** 3759157Sache * @file pat_trie_/debug_fn_imps.hpp 3859157Sache * Contains an implementation class for pat_trie_. 3959157Sache */ 4059157Sache 4159157Sache#ifdef PB_DS_CLASS_C_DEC 4259157Sache 4359157Sache#ifdef _GLIBCXX_DEBUG 4459157Sache 4559157SachePB_DS_CLASS_T_DEC 4659157Sachevoid 4759157SachePB_DS_CLASS_C_DEC:: 4886799Sacheassert_valid(const char* __file, int __line) const 4959157Sache{ 5059157Sache if (m_p_head->m_p_parent != 0) 5159157Sache m_p_head->m_p_parent->assert_valid(this, __file, __line); 5259157Sache assert_iterators(__file, __line); 5359157Sache assert_reverse_iterators(__file, __line); 5459157Sache if (m_p_head->m_p_parent == 0) 5559157Sache { 5659157Sache PB_DS_DEBUG_VERIFY(m_p_head->m_p_min == m_p_head); 5786799Sache PB_DS_DEBUG_VERIFY(m_p_head->m_p_max == m_p_head); 5859157Sache PB_DS_DEBUG_VERIFY(empty()); 5959157Sache return; 6059157Sache } 6159157Sache 6259157Sache PB_DS_DEBUG_VERIFY(m_p_head->m_p_min->m_type == leaf_node); 6359157Sache PB_DS_DEBUG_VERIFY(m_p_head->m_p_max->m_type == leaf_node); 6459157Sache PB_DS_DEBUG_VERIFY(!empty()); 6559157Sache} 6659157Sache 6759157SachePB_DS_CLASS_T_DEC 6859157Sachevoid 6959157SachePB_DS_CLASS_C_DEC:: 7059157Sacheassert_iterators(const char* __file, int __line) const 7159157Sache{ 7259157Sache size_type calc_size = 0; 7359157Sache for (const_iterator it = begin(); it != end(); ++it) 7459157Sache { 7559157Sache ++calc_size; 7659157Sache debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line); 7759157Sache PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)) == it); 7859157Sache PB_DS_DEBUG_VERIFY(--upper_bound(PB_DS_V2F(*it)) == it); 7959157Sache } 8059157Sache PB_DS_DEBUG_VERIFY(calc_size == m_size); 8159157Sache} 8259157Sache 8359157SachePB_DS_CLASS_T_DEC 8459157Sachevoid 8559157SachePB_DS_CLASS_C_DEC:: 8659157Sacheassert_reverse_iterators(const char* __file, int __line) const 8759157Sache{ 8859157Sache size_type calc_size = 0; 8959157Sache for (const_reverse_iterator it = rbegin(); it != rend(); ++it) 9059157Sache { 9159157Sache ++calc_size; 9259157Sache node_const_pointer p_nd = 9359157Sache const_cast<PB_DS_CLASS_C_DEC*>(this)->find_imp(PB_DS_V2F(*it)); 9459157Sache PB_DS_DEBUG_VERIFY(p_nd == it.m_p_nd); 9559157Sache } 9659157Sache PB_DS_DEBUG_VERIFY(calc_size == m_size); 97} 98 99PB_DS_CLASS_T_DEC 100typename PB_DS_CLASS_C_DEC::size_type 101PB_DS_CLASS_C_DEC:: 102recursive_count_leafs(node_const_pointer p_nd, const char* __file, int __line) 103{ 104 if (p_nd == 0) 105 return (0); 106 if (p_nd->m_type == leaf_node) 107 return (1); 108 PB_DS_DEBUG_VERIFY(p_nd->m_type == i_node); 109 size_type ret = 0; 110 for (typename inode::const_iterator it = static_cast<inode_const_pointer>(p_nd)->begin(); 111 it != static_cast<inode_const_pointer>(p_nd)->end(); 112 ++it) 113 ret += recursive_count_leafs(*it, __file, __line); 114 return ret; 115} 116 117#endif 118#endif 119