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 constructors_destructor_fn_imps.hpp 44107546Simp * Contains an implementation for thin_heap_. 45106844Smdodd */ 4669783Smsmith 4769783SmsmithPB_DS_CLASS_T_DEC 4869783Smsmithtemplate<typename It> 49119285Simpvoid 50119285SimpPB_DS_CLASS_C_DEC:: 51119285Simpcopy_from_range(It first_it, It last_it) 5269783Smsmith{ 5369783Smsmith while (first_it != last_it) 5469783Smsmith push(*(first_it++)); 55200341Sjkim _GLIBCXX_DEBUG_ONLY(assert_valid();) 56200341Sjkim} 57200341Sjkim 58200341SjkimPB_DS_CLASS_T_DEC 59200341SjkimPB_DS_CLASS_C_DEC:: 60200341Sjkimthin_heap_() : 61200341Sjkim m_p_max(NULL) 62200341Sjkim{ 63200341Sjkim initialize(); 6469783Smsmith _GLIBCXX_DEBUG_ONLY(assert_valid();) 65200341Sjkim} 66200341Sjkim 6769783SmsmithPB_DS_CLASS_T_DEC 6869783SmsmithPB_DS_CLASS_C_DEC:: 6969783Smsmiththin_heap_(const Cmp_Fn& r_cmp_fn) : 7069783Smsmith PB_DS_BASE_C_DEC(r_cmp_fn), 7169783Smsmith m_p_max(NULL) 72145661Simp{ 7369783Smsmith initialize(); 74200341Sjkim _GLIBCXX_DEBUG_ONLY(assert_valid();) 75200341Sjkim} 7669783Smsmith 7769783SmsmithPB_DS_CLASS_T_DEC 7869783SmsmithPB_DS_CLASS_C_DEC:: 7969783Smsmiththin_heap_(const PB_DS_CLASS_C_DEC& other) : 8069783Smsmith PB_DS_BASE_C_DEC(other) 8169783Smsmith{ 8269783Smsmith initialize(); 8369783Smsmith m_p_max = base_type::m_p_root; 8469783Smsmith for (node_pointer p_nd = base_type::m_p_root; p_nd != NULL; p_nd = p_nd->m_p_next_sibling) 8569783Smsmith if (Cmp_Fn::operator()(m_p_max->m_value, p_nd->m_value)) 8669783Smsmith m_p_max = p_nd; 8769783Smsmith 8869783Smsmith _GLIBCXX_DEBUG_ONLY(assert_valid();) 8969783Smsmith} 9069783Smsmith 9169783SmsmithPB_DS_CLASS_T_DEC 9269783Smsmithvoid 93164264SjhbPB_DS_CLASS_C_DEC:: 94164264Sjhbswap(PB_DS_CLASS_C_DEC& other) 95164264Sjhb{ 96164264Sjhb _GLIBCXX_DEBUG_ONLY(assert_valid();) 97169221Sjhb base_type::swap(other); 9869783Smsmith std::swap(m_p_max, other.m_p_max); 9969783Smsmith _GLIBCXX_DEBUG_ONLY(assert_valid();) 10069783Smsmith} 10169783Smsmith 102154079SjhbPB_DS_CLASS_T_DEC 10369783SmsmithPB_DS_CLASS_C_DEC:: 104154079Sjhb~thin_heap_() 10569783Smsmith{ } 10669783Smsmith 10769783SmsmithPB_DS_CLASS_T_DEC 108163805Simpvoid 109163805SimpPB_DS_CLASS_C_DEC:: 110163805Simpinitialize() 111163805Simp{ std::fill(m_a_aux, m_a_aux + max_rank, static_cast<node_pointer>(NULL)); } 112163805Simp 113163805Simp