stl_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 __SGI_STL_HASH_FUN_H
00032 #define __SGI_STL_HASH_FUN_H
00033 
00034 #ifndef UNDER_CE
00035 #include <stddef.h>
00036 #else
00037 #include <wce_defs.h>
00038 #endif /* UNDER_CE */
00039 
00040 __STL_BEGIN_NAMESPACE
00041 
00042 template <class _Key> struct hash { };
00043 
00044 inline size_t __stl_hash_string(const char* __s)
00045 {
00046   unsigned long __h = 0; 
00047   for ( ; *__s; ++__s)
00048     __h = 5*__h + *__s;
00049   
00050   return size_t(__h);
00051 }
00052 
00053 __STL_TEMPLATE_NULL struct hash<char*>
00054 {
00055   size_t operator()(const char* __s) const { return __stl_hash_string(__s); }
00056 };
00057 
00058 __STL_TEMPLATE_NULL struct hash<const char*>
00059 {
00060   size_t operator()(const char* __s) const { return __stl_hash_string(__s); }
00061 };
00062 
00063 __STL_TEMPLATE_NULL struct hash<char> {
00064   size_t operator()(char __x) const { return __x; }
00065 };
00066 __STL_TEMPLATE_NULL struct hash<unsigned char> {
00067   size_t operator()(unsigned char __x) const { return __x; }
00068 };
00069 __STL_TEMPLATE_NULL struct hash<signed char> {
00070   size_t operator()(unsigned char __x) const { return __x; }
00071 };
00072 __STL_TEMPLATE_NULL struct hash<short> {
00073   size_t operator()(short __x) const { return __x; }
00074 };
00075 __STL_TEMPLATE_NULL struct hash<unsigned short> {
00076   size_t operator()(unsigned short __x) const { return __x; }
00077 };
00078 __STL_TEMPLATE_NULL struct hash<int> {
00079   size_t operator()(int __x) const { return __x; }
00080 };
00081 __STL_TEMPLATE_NULL struct hash<unsigned int> {
00082   size_t operator()(unsigned int __x) const { return __x; }
00083 };
00084 __STL_TEMPLATE_NULL struct hash<long> {
00085   size_t operator()(long __x) const { return __x; }
00086 };
00087 __STL_TEMPLATE_NULL struct hash<unsigned long> {
00088   size_t operator()(unsigned long __x) const { return __x; }
00089 };
00090 
00091 __STL_END_NAMESPACE
00092 
00093 #endif /* __SGI_STL_HASH_FUN_H */
00094 
00095 // Local Variables:
00096 // mode:C++
00097 // End:

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