OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [include/] [ext/] [pb_assoc/] [detail/] [cc_ht_map_/] [resize_fn_imps.hpp] - Blame information for rev 17

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 jlechner
// -*- C++ -*-
2
 
3
// Copyright (C) 2005 Free Software Foundation, Inc.
4
//
5
// This file is part of the GNU ISO C++ Library.  This library is free
6
// software; you can redistribute it and/or modify it under the
7
// terms of the GNU General Public License as published by the
8
// Free Software Foundation; either version 2, or (at your option)
9
// any later version.
10
 
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
 
16
// You should have received a copy of the GNU General Public License along
17
// with this library; see the file COPYING.  If not, write to the Free
18
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19
// USA.
20
 
21
// As a special exception, you may use this file as part of a free software
22
// library without restriction.  Specifically, if other files instantiate
23
// templates or use macros or inline functions from this file, or you compile
24
// this file and link it with other files to produce an executable, this
25
// file does not by itself cause the resulting executable to be covered by
26
// the GNU General Public License.  This exception does not however
27
// invalidate any other reasons why the executable file might be covered by
28
// the GNU General Public License.
29
 
30
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
31
 
32
// Permission to use, copy, modify, sell, and distribute this software
33
// is hereby granted without fee, provided that the above copyright
34
// notice appears in all copies, and that both that copyright notice and
35
// this permission notice appear in supporting documentation. None of
36
// the above authors, nor IBM Haifa Research Laboratories, make any
37
// representation about the suitability of this software for any
38
// purpose. It is provided "as is" without express or implied warranty.
39
 
40
/**
41
 * @file resize_fn_imps.hpp
42
 * Contains implementations of cc_ht_map_'s resize related functions.
43
 */
44
 
45
PB_ASSOC_CLASS_T_DEC
46
inline bool
47
PB_ASSOC_CLASS_C_DEC::
48
do_resize_if_needed()
49
{
50
  if (!my_resize_base::is_resize_needed())
51
    return (false);
52
 
53
  do
54
    do_resize(my_resize_base::get_new_size(m_num_e_p, m_num_used_e));
55
  while (my_resize_base::is_resize_needed());
56
 
57
  return (true);
58
}
59
 
60
PB_ASSOC_CLASS_T_DEC
61
inline void
62
PB_ASSOC_CLASS_C_DEC::
63
do_resize_if_needed_no_throw()
64
{
65
  if (!my_resize_base::is_resize_needed())
66
    return;
67
 
68
  try
69
    {
70
      do
71
        do_resize(my_resize_base::get_new_size(m_num_e_p, m_num_used_e));
72
      while (my_resize_base::is_resize_needed());
73
    }
74
  catch(...)
75
    { }
76
 
77
  PB_ASSOC_DBG_ONLY(assert_valid();)
78
    }
79
 
80
PB_ASSOC_CLASS_T_DEC
81
void
82
PB_ASSOC_CLASS_C_DEC::
83
do_resize(size_type new_size)
84
{
85
  PB_ASSOC_DBG_ONLY(assert_valid();)
86
 
87
    const size_type old_size = m_num_e_p;
88
 
89
  entry_pointer_array a_p_entries_resized;
90
 
91
  // Following line might throw an exception.
92
 
93
  my_ranged_hash_fn_base::notify_resized(new_size);
94
 
95
  try
96
    {
97
      // Following line might throw an exception.
98
 
99
      a_p_entries_resized = s_entry_pointer_allocator.allocate(new_size);
100
 
101
      m_num_e_p = new_size;
102
    }
103
  catch(...)
104
    {
105
      my_ranged_hash_fn_base::notify_resized(old_size);
106
 
107
      throw;
108
    }
109
 
110
  // At this point no exceptions can be thrown.
111
 
112
  resize_imp_no_exceptions(new_size, a_p_entries_resized, old_size);
113
 
114
  Resize_Policy::notify_resized(new_size);
115
 
116
  PB_ASSOC_DBG_ONLY(assert_valid();)
117
    }
118
 
119
PB_ASSOC_CLASS_T_DEC
120
void
121
PB_ASSOC_CLASS_C_DEC::
122
resize_imp_no_exceptions(size_type new_size, entry_pointer_array a_p_entries_resized, size_type old_size)
123
{
124
  std::fill(a_p_entries_resized, a_p_entries_resized + m_num_e_p,(entry_pointer)NULL);
125
 
126
  for (size_type pos = 0; pos < old_size; ++pos)
127
    {
128
      entry_pointer p_e = m_a_p_entries[pos];
129
 
130
      while (p_e != NULL)
131
        p_e = resize_imp_no_exceptions_reassign_pointer(p_e, a_p_entries_resized, my_hash_traits_base::s_store_hash_indicator);
132
    }
133
 
134
  m_num_e_p = new_size;
135
 
136
  PB_ASSOC_DBG_ONLY(assert_entry_pointer_array_valid(a_p_entries_resized);)
137
 
138
    s_entry_pointer_allocator.deallocate(m_a_p_entries, old_size);
139
 
140
  m_a_p_entries = a_p_entries_resized;
141
 
142
  PB_ASSOC_DBG_ONLY(assert_valid();)
143
    }
144
 
145
#include <ext/pb_assoc/detail/cc_ht_map_/resize_no_store_hash_fn_imps.hpp>
146
#include <ext/pb_assoc/detail/cc_ht_map_/resize_store_hash_fn_imps.hpp>

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.