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/] [standard_policies.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 standard_policies.hpp
42
 * Contains standard policies for containers.
43
 */
44
 
45
#ifndef STANDARD_POLICIES_HPP
46
#define STANDARD_POLICIES_HPP
47
 
48
#include <memory>
49
#include <ext/pb_assoc/hash_policy.hpp>
50
#include <ext/pb_assoc/lu_policy.hpp>
51
#include <ext/pb_assoc/tree_policy.hpp>
52
#if defined(__GNUC__)
53
#include <ext/hash_map>
54
#elif defined(_MSC_VER)
55
#include <hash_map>
56
#else
57
#error "Unable to determine the namespaces for your compiler. Please" \
58
        "Contact pbassoc@gmail.com"
59
#endif // #if defined(__GNUC__)
60
 
61
namespace pb_assoc
62
{
63
 
64
  namespace detail
65
  {
66
 
67
#ifdef __GNUC__
68
 
69
#define PB_ASSOC_HASH_NAMESPACE \
70
        __gnu_cxx
71
 
72
    template<typename Key>
73
    struct def_hash_fn
74
    {
75
      typedef PB_ASSOC_HASH_NAMESPACE::hash<Key> type;
76
    };
77
 
78
    template<typename Key>
79
    struct def_eq_fn
80
    {
81
      typedef PB_ASSOC_HASH_NAMESPACE::equal_to<Key> type;
82
    };
83
 
84
#elif defined(_MSC_VER)
85
 
86
    template<typename Key>
87
    struct hash_value_class_adapter
88
    {
89
      inline size_t
90
      operator()(const Key& r_key) const
91
      {
92
        return (stdext::hash_value(r_key));
93
      }
94
    };
95
 
96
    template<typename Key>
97
    struct def_hash_fn
98
    {
99
      typedef hash_value_class_adapter<Key> type;
100
    };
101
 
102
    template<typename Key>
103
    struct def_eq_fn
104
    {
105
      typedef std::equal_to<Key> type;
106
    };
107
 
108
#else // #elif defined(_MSC_VER)
109
 
110
#error Sorry, cannot determine headers, namespaces, etc. for your compiler.
111
#error If you encounter this error, pls write to pbassoc@gmail.com
112
 
113
#endif // #elif defined(_MSC_VER)
114
 
115
    enum
116
      {
117
        def_store_hash = false
118
      };
119
 
120
    struct def_comb_hash_fn
121
    {
122
      typedef pb_assoc::direct_mask_range_hashing<> type;
123
    };
124
 
125
    template<class Comb_Hash_Fn>
126
    struct def_resize_policy
127
    {
128
    private:
129
      typedef typename Comb_Hash_Fn::size_type size_type;
130
 
131
      typedef
132
      typename pb_assoc::detail::cond_type<
133
        pb_assoc::detail::is_same_type<
134
        pb_assoc::direct_mask_range_hashing<size_type>,
135
        Comb_Hash_Fn>::value,
136
        pb_assoc::hash_exponential_size_policy<
137
        size_type>,
138
        pb_assoc::hash_prime_size_policy>::type
139
      size_policy_type;
140
 
141
    public:
142
      typedef
143
      pb_assoc::hash_standard_resize_policy<
144
        size_policy_type,
145
        pb_assoc::hash_load_check_resize_trigger<
146
        false,
147
        size_type>,
148
        false,
149
        size_type>
150
      type;
151
    };
152
 
153
    struct def_update_policy
154
    {
155
      typedef pb_assoc::move_to_front_lu_policy<> type;
156
    };
157
 
158
#ifdef __GNUC__
159
#undef PB_ASSOC_HASH_NAMESPACE
160
#endif // #ifdef __GNUC__
161
 
162
    template<class Comb_Probe_Fn>
163
    struct def_probe_fn
164
    {
165
    private:
166
      typedef typename Comb_Probe_Fn::size_type size_type;
167
 
168
    public:
169
      typedef
170
      typename pb_assoc::detail::cond_type<
171
        pb_assoc::detail::is_same_type<
172
        pb_assoc::direct_mask_range_hashing<size_t>,
173
        Comb_Probe_Fn>::value,
174
        pb_assoc::linear_probe_fn<
175
        size_type>,
176
        pb_assoc::quadratic_probe_fn<
177
        size_type> >::type
178
      type;
179
    };
180
 
181
    typedef pb_assoc::null_node_updator def_node_updator;
182
 
183
  } // namespace detail
184
 
185
} // namespace pb_assoc
186
 
187
#endif // #ifndef STANDARD_POLICIES_HPP
188
 

powered by: WebSVN 2.1.0

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