00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00045 #ifndef STANDARD_POLICIES_HPP
00046 #define STANDARD_POLICIES_HPP
00047 
00048 #include <memory>
00049 #include <ext/pb_assoc/hash_policy.hpp>
00050 #include <ext/pb_assoc/lu_policy.hpp>
00051 #include <ext/pb_assoc/tree_policy.hpp>
00052 #if defined(__GNUC__)
00053 #include <ext/hash_map>
00054 #elif defined(_MSC_VER)
00055 #include <hash_map>
00056 #else
00057 #error "Unable to determine the namespaces for your compiler. Please" \
00058     "Contact pbassoc@gmail.com"
00059 #endif // #if defined(__GNUC__)
00060 
00061 namespace pb_assoc
00062 {
00063 
00064   namespace detail
00065   {
00066 
00067 #ifdef __GNUC__
00068 
00069 #define PB_ASSOC_HASH_NAMESPACE \
00070     __gnu_cxx
00071 
00072     template<typename Key>
00073     struct def_hash_fn
00074     {
00075       typedef PB_ASSOC_HASH_NAMESPACE::hash<Key> type;
00076     };
00077 
00078     template<typename Key>
00079     struct def_eq_fn
00080     {
00081       typedef PB_ASSOC_HASH_NAMESPACE::equal_to<Key> type;
00082     };
00083 
00084 #elif defined(_MSC_VER)
00085 
00086     template<typename Key>
00087     struct hash_value_class_adapter
00088     {
00089       inline size_t
00090       operator()(const Key& r_key) const
00091       {
00092     return (stdext::hash_value(r_key));
00093       }
00094     };
00095 
00096     template<typename Key>
00097     struct def_hash_fn
00098     {
00099       typedef hash_value_class_adapter<Key> type;
00100     };
00101 
00102     template<typename Key>
00103     struct def_eq_fn
00104     {
00105       typedef std::equal_to<Key> type;
00106     };
00107 
00108 #else // #elif defined(_MSC_VER)
00109 
00110 #error Sorry, cannot determine headers, namespaces, etc. for your compiler.
00111 #error If you encounter this error, pls write to pbassoc@gmail.com
00112 
00113 #endif // #elif defined(_MSC_VER)
00114 
00115     enum
00116       {
00117     def_store_hash = false
00118       };
00119 
00120     struct def_comb_hash_fn
00121     {
00122       typedef pb_assoc::direct_mask_range_hashing<> type;
00123     };
00124 
00125     template<class Comb_Hash_Fn>
00126     struct def_resize_policy
00127     {
00128     private:
00129       typedef typename Comb_Hash_Fn::size_type size_type;
00130 
00131       typedef
00132       typename pb_assoc::detail::cond_type<
00133     pb_assoc::detail::is_same_type<
00134     pb_assoc::direct_mask_range_hashing<size_type>,
00135     Comb_Hash_Fn>::value,
00136     pb_assoc::hash_exponential_size_policy<
00137     size_type>,
00138     pb_assoc::hash_prime_size_policy>::type
00139       size_policy_type;
00140 
00141     public:
00142       typedef
00143       pb_assoc::hash_standard_resize_policy<
00144     size_policy_type,
00145     pb_assoc::hash_load_check_resize_trigger<
00146     false,
00147     size_type>,
00148     false,
00149     size_type>
00150       type;
00151     };
00152 
00153     struct def_update_policy
00154     {
00155       typedef pb_assoc::move_to_front_lu_policy<> type;
00156     };
00157 
00158 #ifdef __GNUC__
00159 #undef PB_ASSOC_HASH_NAMESPACE
00160 #endif // #ifdef __GNUC__
00161 
00162     template<class Comb_Probe_Fn>
00163     struct def_probe_fn
00164     {
00165     private:
00166       typedef typename Comb_Probe_Fn::size_type size_type;
00167 
00168     public:
00169       typedef
00170       typename pb_assoc::detail::cond_type<
00171     pb_assoc::detail::is_same_type<
00172     pb_assoc::direct_mask_range_hashing<size_t>,
00173     Comb_Probe_Fn>::value,
00174     pb_assoc::linear_probe_fn<
00175     size_type>,
00176     pb_assoc::quadratic_probe_fn<
00177     size_type> >::type
00178       type;
00179     };
00180 
00181     typedef pb_assoc::null_node_updator def_node_updator;
00182 
00183   } 
00184 
00185 } 
00186 
00187 #endif // #ifndef STANDARD_POLICIES_HPP
00188