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 #ifndef _STLP_HASH_FUN_H
00032 #define _STLP_HASH_FUN_H
00033
00034 # ifndef _STLP_CSTDDEF
00035 # include <cstddef>
00036 # endif
00037
00038 _STLP_BEGIN_NAMESPACE
00039
00040 template <class _Key> struct hash { };
00041
00042 inline size_t __stl_hash_string(const char* __s)
00043 {
00044 _STLP_FIX_LITERAL_BUG(__s)
00045 unsigned long __h = 0;
00046 for ( ; *__s; ++__s)
00047 __h = 5*__h + *__s;
00048
00049 return size_t(__h);
00050 }
00051
00052 _STLP_TEMPLATE_NULL struct hash<char*>
00053 {
00054 size_t operator()(const char* __s) const { _STLP_FIX_LITERAL_BUG(__s) return __stl_hash_string(__s); }
00055 };
00056
00057 _STLP_TEMPLATE_NULL struct hash<const char*>
00058 {
00059 size_t operator()(const char* __s) const { _STLP_FIX_LITERAL_BUG(__s) return __stl_hash_string(__s); }
00060 };
00061
00062 _STLP_TEMPLATE_NULL struct hash<char> {
00063 size_t operator()(char __x) const { return __x; }
00064 };
00065 _STLP_TEMPLATE_NULL struct hash<unsigned char> {
00066 size_t operator()(unsigned char __x) const { return __x; }
00067 };
00068 #ifndef _STLP_NO_SIGNED_BUILTINS
00069 _STLP_TEMPLATE_NULL struct hash<signed char> {
00070 size_t operator()(unsigned char __x) const { return __x; }
00071 };
00072 #endif
00073 _STLP_TEMPLATE_NULL struct hash<short> {
00074 size_t operator()(short __x) const { return __x; }
00075 };
00076 _STLP_TEMPLATE_NULL struct hash<unsigned short> {
00077 size_t operator()(unsigned short __x) const { return __x; }
00078 };
00079 _STLP_TEMPLATE_NULL struct hash<int> {
00080 size_t operator()(int __x) const { return __x; }
00081 };
00082 _STLP_TEMPLATE_NULL struct hash<unsigned int> {
00083 size_t operator()(unsigned int __x) const { return __x; }
00084 };
00085 _STLP_TEMPLATE_NULL struct hash<long> {
00086 size_t operator()(long __x) const { return __x; }
00087 };
00088 _STLP_TEMPLATE_NULL struct hash<unsigned long> {
00089 size_t operator()(unsigned long __x) const { return __x; }
00090 };
00091
00092 # if defined (_STLP_LONG_LONG)
00093 _STLP_TEMPLATE_NULL struct hash<_STLP_LONG_LONG> {
00094 size_t operator()(long x) const { return x; }
00095 };
00096 _STLP_TEMPLATE_NULL struct hash<unsigned _STLP_LONG_LONG> {
00097 size_t operator()(unsigned long x) const { return x; }
00098 };
00099 # endif
00100
00101 _STLP_END_NAMESPACE
00102
00103 #endif
00104
00105
00106
00107