Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

stl_hash_fun.h

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

Generated at Tue May 1 16:28:39 2001 for libstdc++-v3 by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001