r_erase_fn_imps.hpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2005 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // You should have received a copy of the GNU General Public License along
00017 // with this library; see the file COPYING.  If not, write to the Free
00018 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00019 // USA.
00020 
00021 // As a special exception, you may use this file as part of a free software
00022 // library without restriction.  Specifically, if other files instantiate
00023 // templates or use macros or inline functions from this file, or you compile
00024 // this file and link it with other files to produce an executable, this
00025 // file does not by itself cause the resulting executable to be covered by
00026 // the GNU General Public License.  This exception does not however
00027 // invalidate any other reasons why the executable file might be covered by
00028 // the GNU General Public License.
00029 
00030 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
00031 
00032 // Permission to use, copy, modify, sell, and distribute this software
00033 // is hereby granted without fee, provided that the above copyright
00034 // notice appears in all copies, and that both that copyright notice and
00035 // this permission notice appear in supporting documentation. None of
00036 // the above authors, nor IBM Haifa Research Laboratories, make any
00037 // representation about the suitability of this software for any
00038 // purpose. It is provided "as is" without express or implied warranty.
00039 
00045 PB_ASSOC_CLASS_T_DEC
00046 inline void
00047 PB_ASSOC_CLASS_C_DEC::
00048 actual_erase_node(node_pointer p_z)
00049 {
00050   PB_ASSOC_DBG_ASSERT(m_size > 0);
00051   --m_size;
00052 
00053   PB_ASSOC_DBG_ONLY(erase_existing(PB_ASSOC_V2F(p_z->m_value)));
00054 
00055   p_z->~node();
00056 
00057   s_node_allocator.deallocate(p_z, 1);
00058 }
00059 
00060 PB_ASSOC_CLASS_T_DEC
00061 inline void
00062 PB_ASSOC_CLASS_C_DEC::
00063 update_min_max_for_erased_node(node_pointer p_z)
00064 {
00065   if (m_size == 1)
00066     {
00067       m_p_head->m_p_left = m_p_head->m_p_right = m_p_head;
00068 
00069       return;
00070     }
00071 
00072   if (m_p_head->m_p_left == p_z)
00073     {
00074       iterator it(p_z);
00075 
00076       ++it;
00077 
00078       m_p_head->m_p_left = it.m_p_nd;
00079     }
00080   else if (m_p_head->m_p_right == p_z)
00081     {
00082       iterator it(p_z);
00083 
00084       --it;
00085 
00086       m_p_head->m_p_right = it.m_p_nd;
00087     }
00088 }
00089 
00090 PB_ASSOC_CLASS_T_DEC
00091 void
00092 PB_ASSOC_CLASS_C_DEC::
00093 clear()
00094 {
00095   PB_ASSOC_DBG_ONLY(assert_valid(true, true);)
00096 
00097     clear_imp(m_p_head->m_p_parent);
00098 
00099   m_size = 0;
00100 
00101   initialize();
00102 
00103   PB_ASSOC_DBG_ONLY(my_map_debug_base::clear();)
00104 
00105     PB_ASSOC_DBG_ONLY(assert_valid(true, true);)
00106     }
00107 
00108 PB_ASSOC_CLASS_T_DEC
00109 void
00110 PB_ASSOC_CLASS_C_DEC::
00111 clear_imp(node_pointer p_nd)
00112 {
00113   if (p_nd == NULL)
00114     return;
00115 
00116   clear_imp(p_nd->m_p_left);
00117 
00118   clear_imp(p_nd->m_p_right);
00119 
00120   p_nd->~Node();
00121 
00122   s_node_allocator.deallocate(p_nd, 1);
00123 }
00124 

Generated on Tue Feb 2 16:56:21 2010 for GNU C++ STL by  doxygen 1.4.7