1251876Speter// -*- C++ -*-
2251876Speter
3251876Speter// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
4251876Speter//
5251876Speter// This file is part of the GNU ISO C++ Library.  This library is free
6251876Speter// software; you can redistribute it and/or modify it under the terms
7251876Speter// of the GNU General Public License as published by the Free Software
8251876Speter// Foundation; either version 2, or (at your option) any later
9251876Speter// version.
10251876Speter
11251876Speter// This library is distributed in the hope that it will be useful, but
12251876Speter// WITHOUT ANY WARRANTY; without even the implied warranty of
13251876Speter// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14251876Speter// General Public License for more details.
15251876Speter
16251876Speter// You should have received a copy of the GNU General Public License
17251876Speter// along with this library; see the file COPYING.  If not, write to
18251876Speter// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
19251876Speter// MA 02111-1307, USA.
20251876Speter
21251876Speter// As a special exception, you may use this file as part of a free
22251876Speter// software library without restriction.  Specifically, if other files
23251876Speter// instantiate templates or use macros or inline functions from this
24251876Speter// file, or you compile this file and link it with other files to
25251876Speter// produce an executable, this file does not by itself cause the
26251876Speter// resulting executable to be covered by the GNU General Public
27251876Speter// License.  This exception does not however invalidate any other
28251876Speter// reasons why the executable file might be covered by the GNU General
29251876Speter// Public License.
30251876Speter
31251876Speter// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
32251876Speter
33251876Speter// Permission to use, copy, modify, sell, and distribute this software
34251876Speter// is hereby granted without fee, provided that the above copyright
35251876Speter// notice appears in all copies, and that both that copyright notice
36251876Speter// and this permission notice appear in supporting documentation. None
37251876Speter// of the above authors, nor IBM Haifa Research Laboratories, make any
38251876Speter// representation about the suitability of this software for any
39251876Speter// purpose. It is provided "as is" without express or implied
40251876Speter// warranty.
41251876Speter
42251876Speter/**
43251876Speter * @file erase_fn_imps.hpp
44251876Speter * Contains an implementation for rc_binomial_heap_.
45251876Speter */
46251876Speter
47251876SpeterPB_DS_CLASS_T_DEC
48251876Speterinline void
49251876SpeterPB_DS_CLASS_C_DEC::
50251876Speterpop()
51251876Speter{
52251876Speter  make_binomial_heap();
53251876Speter  _GLIBCXX_DEBUG_ASSERT(!base_type::empty());
54251876Speter  base_type::pop();
55251876Speter  base_type::find_max();
56251876Speter}
57251876Speter
58251876SpeterPB_DS_CLASS_T_DEC
59251876Spetervoid
60251876SpeterPB_DS_CLASS_C_DEC::
61251876Speterclear()
62251876Speter{
63251876Speter  base_type::clear();
64251876Speter  m_rc.clear();
65251876Speter}
66251876Speter
67251876SpeterPB_DS_CLASS_T_DEC
68251876Spetervoid
69251876SpeterPB_DS_CLASS_C_DEC::
70251876Spetermake_binomial_heap()
71251876Speter{
72251876Speter  node_pointer p_nd = base_type::m_p_root;
73251876Speter  while (p_nd != NULL)
74251876Speter    {
75251876Speter      node_pointer p_next = p_nd->m_p_next_sibling;
76251876Speter      if (p_next == NULL)
77251876Speter	p_nd = p_next;
78251876Speter      else if (p_nd->m_metadata == p_next->m_metadata)
79251876Speter	p_nd = link_with_next_sibling(p_nd);
80251876Speter      else if (p_nd->m_metadata < p_next->m_metadata)
81251876Speter	p_nd = p_next;
82251876Speter#ifdef _GLIBCXX_DEBUG
83251876Speter      else
84251876Speter	_GLIBCXX_DEBUG_ASSERT(0);
85251876Speter#endif
86251876Speter    }
87251876Speter
88251876Speter  m_rc.clear();
89251876Speter}
90251876Speter
91251876SpeterPB_DS_CLASS_T_DEC
92251876Spetertemplate<typename Pred>
93251876Spetertypename PB_DS_CLASS_C_DEC::size_type
94251876SpeterPB_DS_CLASS_C_DEC::
95251876Spetererase_if(Pred pred)
96251876Speter{
97251876Speter  make_binomial_heap();
98251876Speter  const size_type ersd = base_type::erase_if(pred);
99251876Speter  base_type::find_max();
100251876Speter  _GLIBCXX_DEBUG_ONLY(assert_valid();)
101251876Speter  return ersd;
102251876Speter}
103251876Speter
104251876SpeterPB_DS_CLASS_T_DEC
105251876Spetervoid
106251876SpeterPB_DS_CLASS_C_DEC::
107251876Spetererase(point_iterator it)
108251876Speter{
109251876Speter  make_binomial_heap();
110251876Speter  base_type::erase(it);
111251876Speter  base_type::find_max();
112251876Speter}
113251876Speter
114251876Speter