trace_fn_imps.hpp revision 169692
169783Smsmith// -*- C++ -*- 269783Smsmith 369783Smsmith// Copyright (C) 2005, 2006 Free Software Foundation, Inc. 469783Smsmith// 569783Smsmith// This file is part of the GNU ISO C++ Library. This library is free 669783Smsmith// software; you can redistribute it and/or modify it under the terms 769783Smsmith// of the GNU General Public License as published by the Free Software 869783Smsmith// Foundation; either version 2, or (at your option) any later 969783Smsmith// version. 1069783Smsmith 1169783Smsmith// This library is distributed in the hope that it will be useful, but 1269783Smsmith// WITHOUT ANY WARRANTY; without even the implied warranty of 1369783Smsmith// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1469783Smsmith// General Public License for more details. 1569783Smsmith 1669783Smsmith// You should have received a copy of the GNU General Public License 1769783Smsmith// along with this library; see the file COPYING. If not, write to 1869783Smsmith// the Free Software Foundation, 59 Temple Place - Suite 330, Boston, 1969783Smsmith// MA 02111-1307, USA. 2069783Smsmith 2169783Smsmith// As a special exception, you may use this file as part of a free 2269783Smsmith// software library without restriction. Specifically, if other files 2369783Smsmith// instantiate templates or use macros or inline functions from this 2469783Smsmith// file, or you compile this file and link it with other files to 2569783Smsmith// produce an executable, this file does not by itself cause the 2669783Smsmith// resulting executable to be covered by the GNU General Public 2769783Smsmith// License. This exception does not however invalidate any other 2869783Smsmith// reasons why the executable file might be covered by the GNU General 2969783Smsmith// Public License. 3069783Smsmith 31119418Sobrien// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. 32119418Sobrien 33119418Sobrien// Permission to use, copy, modify, sell, and distribute this software 3469783Smsmith// is hereby granted without fee, provided that the above copyright 3569783Smsmith// notice appears in all copies, and that both that copyright notice 3669783Smsmith// and this permission notice appear in supporting documentation. None 3769783Smsmith// of the above authors, nor IBM Haifa Research Laboratories, make any 3869783Smsmith// representation about the suitability of this software for any 3969783Smsmith// purpose. It is provided "as is" without express or implied 4069783Smsmith// warranty. 41129876Sphk 4269783Smsmith/** 43107546Simp * @file trace_fn_imps.hpp 44107546Simp * Contains an implementation class for pat_trie_. 45106844Smdodd */ 4669783Smsmith 4769783Smsmith#ifdef PB_DS_PAT_TRIE_TRACE_ 4869783Smsmith 49119285SimpPB_DS_CLASS_T_DEC 50119285Simpvoid 51119285SimpPB_DS_CLASS_C_DEC:: 5269783Smsmithtrace() const 5369783Smsmith{ 5469783Smsmith std::cerr << std::endl; 5569783Smsmith if (m_p_head->m_p_parent == NULL) 5669783Smsmith return; 5769783Smsmith trace_node(m_p_head->m_p_parent, 0); 5869783Smsmith std::cerr << std::endl; 5969783Smsmith} 6069783Smsmith 61145661SimpPB_DS_CLASS_T_DEC 6269783Smsmithvoid 6369783SmsmithPB_DS_CLASS_C_DEC:: 6469783Smsmithtrace_node(const_node_pointer p_nd, size_type level) 6569783Smsmith{ 6669783Smsmith for (size_type i = 0; i < level; ++i) 6769783Smsmith std::cerr << ' '; 6869783Smsmith std::cerr << p_nd << " "; 6969783Smsmith std::cerr << ((p_nd->m_type == pat_trie_leaf_node_type) ? "l " : "i "); 7069783Smsmith 7169783Smsmith trace_node_metadata(p_nd, type_to_type<typename node::metadata_type>()); 7269783Smsmith typename e_access_traits::const_iterator el_it = pref_begin(p_nd); 7369783Smsmith while (el_it != pref_end(p_nd)) 7469783Smsmith { 7569783Smsmith std::cerr <<* el_it; 7669783Smsmith ++el_it; 7769783Smsmith } 7869783Smsmith 7969783Smsmith if (p_nd->m_type == pat_trie_leaf_node_type) 8069783Smsmith { 8169783Smsmith std::cerr << std::endl; 82164264Sjhb return; 83164264Sjhb } 84164264Sjhb 85164264Sjhb const_internal_node_pointer p_internal = 86169221Sjhb static_cast<const_internal_node_pointer>(p_nd); 8769783Smsmith 8869783Smsmith std::cerr << " " << 8969783Smsmith static_cast<unsigned long>(p_internal->get_e_ind()) << std::endl; 9069783Smsmith 91154079Sjhb const size_type num_children = std::distance(p_internal->begin(), 9269783Smsmith p_internal->end()); 93154079Sjhb 9469783Smsmith for (size_type child_i = 0; child_i < num_children; ++child_i) 9569783Smsmith { 9669783Smsmith typename internal_node::const_iterator child_it = 97163805Simp p_internal->begin(); 98163805Simp std::advance(child_it, num_children - child_i - 1); 99163805Simp trace_node(*child_it, level + 1); 100163805Simp } 101163805Simp} 102163805Simp 103163805SimpPB_DS_CLASS_T_DEC 104163805Simptemplate<typename Metadata_> 105163805Simpvoid 106163805SimpPB_DS_CLASS_C_DEC:: 107163805Simptrace_node_metadata(const_node_pointer p_nd, type_to_type<Metadata_>) 108163805Simp{ 109163805Simp std::cerr << "(" << static_cast<unsigned long>(p_nd->get_metadata()) << ") "; 110163805Simp} 111163805Simp 112163805SimpPB_DS_CLASS_T_DEC 113163805Simpvoid 114163805SimpPB_DS_CLASS_C_DEC:: 115163805Simptrace_node_metadata(const_node_pointer, type_to_type<null_node_metadata>) 116163805Simp{ } 117163805Simp 118163805Simp#endif 119163805Simp 120163805Simp