debug_fn_imps.hpp revision 169691
1181834Sroberto// -*- C++ -*- 2181834Sroberto 3181834Sroberto// Copyright (C) 2005, 2006 Free Software Foundation, Inc. 4181834Sroberto// 5181834Sroberto// This file is part of the GNU ISO C++ Library. This library is free 6181834Sroberto// software; you can redistribute it and/or modify it under the terms 7181834Sroberto// of the GNU General Public License as published by the Free Software 8181834Sroberto// Foundation; either version 2, or (at your option) any later 9181834Sroberto// version. 10181834Sroberto 11181834Sroberto// This library is distributed in the hope that it will be useful, but 12181834Sroberto// WITHOUT ANY WARRANTY; without even the implied warranty of 13181834Sroberto// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14181834Sroberto// General Public License for more details. 15181834Sroberto 16181834Sroberto// You should have received a copy of the GNU General Public License 17181834Sroberto// along with this library; see the file COPYING. If not, write to 18181834Sroberto// the Free Software Foundation, 59 Temple Place - Suite 330, Boston, 19181834Sroberto// MA 02111-1307, USA. 20181834Sroberto 21181834Sroberto// As a special exception, you may use this file as part of a free 22181834Sroberto// software library without restriction. Specifically, if other files 23181834Sroberto// instantiate templates or use macros or inline functions from this 24181834Sroberto// file, or you compile this file and link it with other files to 25181834Sroberto// produce an executable, this file does not by itself cause the 26181834Sroberto// resulting executable to be covered by the GNU General Public 27181834Sroberto// License. This exception does not however invalidate any other 28181834Sroberto// reasons why the executable file might be covered by the GNU General 29181834Sroberto// Public License. 30181834Sroberto 31181834Sroberto// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. 32181834Sroberto 33181834Sroberto// Permission to use, copy, modify, sell, and distribute this software 34181834Sroberto// is hereby granted without fee, provided that the above copyright 35181834Sroberto// notice appears in all copies, and that both that copyright notice 36181834Sroberto// and this permission notice appear in supporting documentation. None 37181834Sroberto// of the above authors, nor IBM Haifa Research Laboratories, make any 38181834Sroberto// representation about the suitability of this software for any 39181834Sroberto// purpose. It is provided "as is" without express or implied 40181834Sroberto// warranty. 41181834Sroberto 42181834Sroberto/** 43181834Sroberto * @file debug_fn_imps.hpp 44181834Sroberto * Contains an implementation for rc_binomial_heap_. 45181834Sroberto */ 46181834Sroberto 47181834Sroberto#ifdef _GLIBCXX_DEBUG 48181834Sroberto 49181834SrobertoPB_DS_CLASS_T_DEC 50181834Srobertovoid 51181834SrobertoPB_DS_CLASS_C_DEC:: 52181834Srobertoassert_valid() const 53181834Sroberto{ 54181834Sroberto base_type::assert_valid(false); 55181834Sroberto if (!base_type::empty()) 56181834Sroberto { 57181834Sroberto _GLIBCXX_DEBUG_ASSERT(base_type::m_p_max != NULL); 58181834Sroberto base_type::assert_max(); 59181834Sroberto } 60181834Sroberto 61181834Sroberto m_rc.assert_valid(); 62181834Sroberto 63181834Sroberto if (m_rc.empty()) 64181834Sroberto { 65181834Sroberto base_type::assert_valid(true); 66181834Sroberto _GLIBCXX_DEBUG_ASSERT(next_2_pointer(base_type::m_p_root) == NULL); 67181834Sroberto return; 68181834Sroberto } 69181834Sroberto 70181834Sroberto const_node_pointer p_nd = next_2_pointer(base_type::m_p_root); 71181834Sroberto typename rc_t::const_iterator it = m_rc.end(); 72181834Sroberto --it; 73181834Sroberto 74181834Sroberto while (p_nd != NULL) 75181834Sroberto { 76181834Sroberto _GLIBCXX_DEBUG_ASSERT(*it == p_nd); 77181834Sroberto const_node_pointer p_next = p_nd->m_p_next_sibling; 78181834Sroberto _GLIBCXX_DEBUG_ASSERT(p_next != NULL); 79181834Sroberto _GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_next->m_metadata); 80181834Sroberto _GLIBCXX_DEBUG_ASSERT(p_next->m_p_next_sibling == NULL || 81181834Sroberto p_next->m_metadata < p_next->m_p_next_sibling->m_metadata); 82181834Sroberto 83181834Sroberto --it; 84181834Sroberto p_nd = next_2_pointer(next_after_0_pointer(p_nd)); 85181834Sroberto } 86181834Sroberto _GLIBCXX_DEBUG_ASSERT(it + 1 == m_rc.begin()); 87181834Sroberto} 88181834Sroberto 89181834SrobertoPB_DS_CLASS_T_DEC 90181834Srobertotypename PB_DS_CLASS_C_DEC::const_node_pointer 91181834SrobertoPB_DS_CLASS_C_DEC:: 92181834Srobertonext_2_pointer(const_node_pointer p_nd) 93181834Sroberto{ 94181834Sroberto if (p_nd == NULL) 95181834Sroberto return NULL; 96181834Sroberto 97181834Sroberto node_pointer p_next = p_nd->m_p_next_sibling; 98181834Sroberto 99181834Sroberto if (p_next == NULL) 100181834Sroberto return NULL; 101181834Sroberto 102181834Sroberto if (p_nd->m_metadata == p_next->m_metadata) 103181834Sroberto return p_nd; 104181834Sroberto 105181834Sroberto return next_2_pointer(p_next); 106181834Sroberto} 107181834Sroberto 108181834SrobertoPB_DS_CLASS_T_DEC 109181834Srobertotypename PB_DS_CLASS_C_DEC::const_node_pointer 110181834SrobertoPB_DS_CLASS_C_DEC:: 111181834Srobertonext_after_0_pointer(const_node_pointer p_nd) 112181834Sroberto{ 113181834Sroberto if (p_nd == NULL) 114181834Sroberto return NULL; 115181834Sroberto 116181834Sroberto node_pointer p_next = p_nd->m_p_next_sibling; 117181834Sroberto 118181834Sroberto if (p_next == NULL) 119181834Sroberto return NULL; 120181834Sroberto 121181834Sroberto if (p_nd->m_metadata < p_next->m_metadata) 122181834Sroberto return p_next; 123181834Sroberto 124181834Sroberto return next_after_0_pointer(p_next); 125181834Sroberto} 126181834Sroberto 127181834Sroberto#endif 128181834Sroberto