150276Speter// -*- C++ -*-
2166124Srafan
350276Speter// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
450276Speter//
550276Speter// This file is part of the GNU ISO C++ Library.  This library is free
650276Speter// software; you can redistribute it and/or modify it under the terms
750276Speter// of the GNU General Public License as published by the Free Software
850276Speter// Foundation; either version 2, or (at your option) any later
950276Speter// version.
1050276Speter
1150276Speter// This library is distributed in the hope that it will be useful, but
1250276Speter// WITHOUT ANY WARRANTY; without even the implied warranty of
1350276Speter// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1450276Speter// General Public License for more details.
1550276Speter
1650276Speter// You should have received a copy of the GNU General Public License
1750276Speter// along with this library; see the file COPYING.  If not, write to
1850276Speter// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
1950276Speter// MA 02111-1307, USA.
2050276Speter
2150276Speter// As a special exception, you may use this file as part of a free
2250276Speter// software library without restriction.  Specifically, if other files
2350276Speter// instantiate templates or use macros or inline functions from this
2450276Speter// file, or you compile this file and link it with other files to
2550276Speter// produce an executable, this file does not by itself cause the
2650276Speter// resulting executable to be covered by the GNU General Public
2750276Speter// License.  This exception does not however invalidate any other
2850276Speter// reasons why the executable file might be covered by the GNU General
29166124Srafan// Public License.
3050276Speter
3150276Speter// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
3250276Speter
3350276Speter// Permission to use, copy, modify, sell, and distribute this software
3450276Speter// is hereby granted without fee, provided that the above copyright
3550276Speter// notice appears in all copies, and that both that copyright notice
3650276Speter// and this permission notice appear in supporting documentation. None
3750276Speter// of the above authors, nor IBM Haifa Research Laboratories, make any
3850276Speter// representation about the suitability of this software for any
3950276Speter// purpose. It is provided "as is" without express or implied
4050276Speter// warranty.
4150276Speter
4250276Speter/**
4350276Speter * @file erase_no_store_hash_fn_imps.hpp
4450276Speter * Contains implementations of cc_ht_map_'s erase related functions,
45166124Srafan * when the hash value is not stored.
4650276Speter */
4750276Speter
4850276SpeterPB_DS_CLASS_T_DEC
4950276Speterinline bool
5050276SpeterPB_DS_CLASS_C_DEC::
5150276Spetererase(const_key_reference r_key)
52166124Srafan{
5350276Speter  _GLIBCXX_DEBUG_ONLY(assert_valid();)
5450276Speter  return erase_in_pos_imp(r_key, ranged_hash_fn_base::operator()(r_key));
55166124Srafan}
5650276Speter
5750276SpeterPB_DS_CLASS_T_DEC
58166124Srafaninline bool
5950276SpeterPB_DS_CLASS_C_DEC::
6050276Spetererase_in_pos_imp(const_key_reference r_key, size_type pos)
6150276Speter{
6250276Speter  _GLIBCXX_DEBUG_ONLY(assert_valid();)
6350276Speter  entry_pointer p_e = m_entries[pos];
6450276Speter  resize_base::notify_erase_search_start();
6550276Speter  if (p_e == NULL)
6650276Speter    {
6750276Speter      resize_base::notify_erase_search_end();
6850276Speter      _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
6950276Speter      _GLIBCXX_DEBUG_ONLY(assert_valid();)
7050276Speter      return false;
7150276Speter    }
7250276Speter
7350276Speter  if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key))
7450276Speter    {
7550276Speter      resize_base::notify_erase_search_end();
7650276Speter      _GLIBCXX_DEBUG_ONLY(map_debug_base:: check_key_exists(r_key);)
77      erase_entry_pointer(m_entries[pos]);
78      do_resize_if_needed_no_throw();
79      _GLIBCXX_DEBUG_ONLY(assert_valid();)
80      return true;
81    }
82
83  while (true)
84    {
85      entry_pointer p_next_e = p_e->m_p_next;
86      if (p_next_e == NULL)
87        {
88	  resize_base::notify_erase_search_end();
89	  _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_does_not_exist(r_key);)
90          _GLIBCXX_DEBUG_ONLY(assert_valid();)
91          return false;
92        }
93
94      if (hash_eq_fn_base::operator()(PB_DS_V2F(p_next_e->m_value), r_key))
95        {
96	  resize_base::notify_erase_search_end();
97	  _GLIBCXX_DEBUG_ONLY(map_debug_base::check_key_exists(r_key);)
98          erase_entry_pointer(p_e->m_p_next);
99	  do_resize_if_needed_no_throw();
100	  _GLIBCXX_DEBUG_ONLY(assert_valid();)
101          return true;
102        }
103      resize_base::notify_erase_search_collision();
104      p_e = p_next_e;
105    }
106}
107
108