_hash_fun.h

00001 /*
00002  * Copyright (c) 1996-1998
00003  * Silicon Graphics Computer Systems, Inc.
00004  *
00005  * Permission to use, copy, modify, distribute and sell this software
00006  * and its documentation for any purpose is hereby granted without fee,
00007  * provided that the above copyright notice appear in all copies and
00008  * that both that copyright notice and this permission notice appear
00009  * in supporting documentation.  Silicon Graphics makes no
00010  * representations about the suitability of this software for any
00011  * purpose.  It is provided "as is" without express or implied warranty.
00012  *
00013  *
00014  * Copyright (c) 1994
00015  * Hewlett-Packard Company
00016  *
00017  * Permission to use, copy, modify, distribute and sell this software
00018  * and its documentation for any purpose is hereby granted without fee,
00019  * provided that the above copyright notice appear in all copies and
00020  * that both that copyright notice and this permission notice appear
00021  * in supporting documentation.  Hewlett-Packard Company makes no
00022  * representations about the suitability of this software for any
00023  * purpose.  It is provided "as is" without express or implied warranty.
00024  *
00025  */
00026 
00027 /* NOTE: This is an internal header file, included by other STL headers.
00028  *   You should not attempt to use it directly.
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 /* _STLP_HASH_FUN_H */
00104 
00105 // Local Variables:
00106 // mode:C++
00107 // End:

Generated on Mon Jun 5 10:20:46 2006 for Intelligence.kdevelop by  doxygen 1.4.6