hash_fun.hxx.in 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*============================================================================
  2. KWSys - Kitware System Library
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. /*
  11. * Copyright (c) 1996
  12. * Silicon Graphics Computer Systems, Inc.
  13. *
  14. * Permission to use, copy, modify, distribute and sell this software
  15. * and its documentation for any purpose is hereby granted without fee,
  16. * provided that the above copyright notice appear in all copies and
  17. * that both that copyright notice and this permission notice appear
  18. * in supporting documentation. Silicon Graphics makes no
  19. * representations about the suitability of this software for any
  20. * purpose. It is provided "as is" without express or implied warranty.
  21. *
  22. *
  23. * Copyright (c) 1994
  24. * Hewlett-Packard Company
  25. *
  26. * Permission to use, copy, modify, distribute and sell this software
  27. * and its documentation for any purpose is hereby granted without fee,
  28. * provided that the above copyright notice appear in all copies and
  29. * that both that copyright notice and this permission notice appear
  30. * in supporting documentation. Hewlett-Packard Company makes no
  31. * representations about the suitability of this software for any
  32. * purpose. It is provided "as is" without express or implied warranty.
  33. *
  34. */
  35. #ifndef @KWSYS_NAMESPACE@_hash_fun_hxx
  36. #define @KWSYS_NAMESPACE@_hash_fun_hxx
  37. #include <@KWSYS_NAMESPACE@/Configure.hxx>
  38. #include <@KWSYS_NAMESPACE@/cstddef> // size_t
  39. namespace @KWSYS_NAMESPACE@
  40. {
  41. template <class _Key> struct hash { };
  42. inline size_t _stl_hash_string(const char* __s)
  43. {
  44. unsigned long __h = 0;
  45. for ( ; *__s; ++__s)
  46. __h = 5*__h + *__s;
  47. return size_t(__h);
  48. }
  49. @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION
  50. struct hash<char*> {
  51. size_t operator()(const char* __s) const { return _stl_hash_string(__s); }
  52. };
  53. @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION
  54. struct hash<const char*> {
  55. size_t operator()(const char* __s) const { return _stl_hash_string(__s); }
  56. };
  57. @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION
  58. struct hash<char> {
  59. size_t operator()(char __x) const { return __x; }
  60. };
  61. @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION
  62. struct hash<unsigned char> {
  63. size_t operator()(unsigned char __x) const { return __x; }
  64. };
  65. @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION
  66. struct hash<signed char> {
  67. size_t operator()(unsigned char __x) const { return __x; }
  68. };
  69. @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION
  70. struct hash<short> {
  71. size_t operator()(short __x) const { return __x; }
  72. };
  73. @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION
  74. struct hash<unsigned short> {
  75. size_t operator()(unsigned short __x) const { return __x; }
  76. };
  77. @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION
  78. struct hash<int> {
  79. size_t operator()(int __x) const { return __x; }
  80. };
  81. @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION
  82. struct hash<unsigned int> {
  83. size_t operator()(unsigned int __x) const { return __x; }
  84. };
  85. @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION
  86. struct hash<long> {
  87. size_t operator()(long __x) const { return __x; }
  88. };
  89. @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION
  90. struct hash<unsigned long> {
  91. size_t operator()(unsigned long __x) const { return __x; }
  92. };
  93. } // namespace @KWSYS_NAMESPACE@
  94. #endif