Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright (c) 1996-1998
  3.  * Silicon Graphics Computer Systems, Inc.
  4.  *
  5.  * Permission to use, copy, modify, distribute and sell this software
  6.  * and its documentation for any purpose is hereby granted without fee,
  7.  * provided that the above copyright notice appear in all copies and
  8.  * that both that copyright notice and this permission notice appear
  9.  * in supporting documentation.  Silicon Graphics makes no
  10.  * representations about the suitability of this software for any
  11.  * purpose.  It is provided "as is" without express or implied warranty.
  12.  *
  13.  *
  14.  * Copyright (c) 1994
  15.  * Hewlett-Packard Company
  16.  *
  17.  * Permission to use, copy, modify, distribute and sell this software
  18.  * and its documentation for any purpose is hereby granted without fee,
  19.  * provided that the above copyright notice appear in all copies and
  20.  * that both that copyright notice and this permission notice appear
  21.  * in supporting documentation.  Hewlett-Packard Company makes no
  22.  * representations about the suitability of this software for any
  23.  * purpose.  It is provided "as is" without express or implied warranty.
  24.  *
  25.  */
  26.  
  27. /* NOTE: This is an internal header file, included by other STL headers.
  28.  *   You should not attempt to use it directly.
  29.  */
  30.  
  31. #ifndef _CPP_BITS_STL_HASH_FUN_H
  32. #define _CPP_BITS_STL_HASH_FUN_H 1
  33.  
  34. #include <bits/std_cstddef.h>
  35.  
  36. namespace std
  37. {
  38.  
  39. template <class _Key> struct hash { };
  40.  
  41. inline size_t __stl_hash_string(const char* __s)
  42. {
  43.   unsigned long __h = 0;
  44.   for ( ; *__s; ++__s)
  45.     __h = 5*__h + *__s;
  46.  
  47.   return size_t(__h);
  48. }
  49.  
  50. template<> struct hash<char*>
  51. {
  52.   size_t operator()(const char* __s) const { return __stl_hash_string(__s); }
  53. };
  54.  
  55. template<> struct hash<const char*>
  56. {
  57.   size_t operator()(const char* __s) const { return __stl_hash_string(__s); }
  58. };
  59.  
  60. template<> struct hash<char> {
  61.   size_t operator()(char __x) const { return __x; }
  62. };
  63. template<> struct hash<unsigned char> {
  64.   size_t operator()(unsigned char __x) const { return __x; }
  65. };
  66. template<> struct hash<signed char> {
  67.   size_t operator()(unsigned char __x) const { return __x; }
  68. };
  69. template<> struct hash<short> {
  70.   size_t operator()(short __x) const { return __x; }
  71. };
  72. template<> struct hash<unsigned short> {
  73.   size_t operator()(unsigned short __x) const { return __x; }
  74. };
  75. template<> struct hash<int> {
  76.   size_t operator()(int __x) const { return __x; }
  77. };
  78. template<> struct hash<unsigned int> {
  79.   size_t operator()(unsigned int __x) const { return __x; }
  80. };
  81. template<> struct hash<long> {
  82.   size_t operator()(long __x) const { return __x; }
  83. };
  84. template<> struct hash<unsigned long> {
  85.   size_t operator()(unsigned long __x) const { return __x; }
  86. };
  87.  
  88. } // namespace std
  89.  
  90. #endif /* _CPP_BITS_STL_HASH_FUN_H */
  91.  
  92. // Local Variables:
  93. // mode:C++
  94. // End:
  95.