ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

_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 _STLP_HASH_FUN_H
00032 #define _STLP_HASH_FUN_H
00033 
00034 #ifndef _STLP_INTERNAL_CSTDDEF
00035 #  include <stl/_cstddef.h>
00036 #endif
00037 
00038 _STLP_BEGIN_NAMESPACE
00039 
00040 template <class _Key> struct hash { };
00041 
00042 _STLP_MOVE_TO_PRIV_NAMESPACE
00043 
00044 inline size_t __stl_hash_string(const char* __s) {
00045   _STLP_FIX_LITERAL_BUG(__s)
00046   unsigned long __h = 0;
00047   for ( ; *__s; ++__s)
00048     __h = 5*__h + *__s;
00049 
00050   return size_t(__h);
00051 }
00052 
00053 _STLP_MOVE_TO_STD_NAMESPACE
00054 
00055 _STLP_TEMPLATE_NULL
00056 struct hash<char*> {
00057   size_t operator()(const char* __s) const {
00058     _STLP_FIX_LITERAL_BUG(__s)
00059     return _STLP_PRIV __stl_hash_string(__s);
00060   }
00061 };
00062 
00063 _STLP_TEMPLATE_NULL
00064 struct hash<const char*> {
00065   size_t operator()(const char* __s) const {
00066     _STLP_FIX_LITERAL_BUG(__s)
00067     return _STLP_PRIV __stl_hash_string(__s);
00068   }
00069 };
00070 
00071 _STLP_TEMPLATE_NULL struct hash<char> {
00072   size_t operator()(char __x) const { return __x; }
00073 };
00074 _STLP_TEMPLATE_NULL struct hash<unsigned char> {
00075   size_t operator()(unsigned char __x) const { return __x; }
00076 };
00077 #if !defined (_STLP_NO_SIGNED_BUILTINS)
00078 _STLP_TEMPLATE_NULL struct hash<signed char> {
00079   size_t operator()(unsigned char __x) const { return __x; }
00080 };
00081 #endif
00082 _STLP_TEMPLATE_NULL struct hash<short> {
00083   size_t operator()(short __x) const { return __x; }
00084 };
00085 _STLP_TEMPLATE_NULL struct hash<unsigned short> {
00086   size_t operator()(unsigned short __x) const { return __x; }
00087 };
00088 _STLP_TEMPLATE_NULL struct hash<int> {
00089   size_t operator()(int __x) const { return __x; }
00090 };
00091 
00092 #if !defined (_STLP_MSVC) || (_STLP_MSVC < 1300) || defined (_WIN64)
00093 _STLP_TEMPLATE_NULL struct hash<unsigned int> {
00094   size_t operator()(unsigned int __x) const { return __x; }
00095 };
00096 #else
00097 /* MSVC .Net since 2002 has a 64 bits portability warning feature. typedef
00098  * like size_t are tagged as potential 64 bits variables making them different from
00099  * unsigned int. To avoid the warning when a hash container is instanciated with
00100  * the size_t key we prefer to grant the size_t specialization rather than the
00101  * unsigned int one.
00102  */
00103 _STLP_TEMPLATE_NULL struct hash<size_t> {
00104   size_t operator()(size_t __x) const { return __x; }
00105 };
00106 #endif
00107 
00108 _STLP_TEMPLATE_NULL struct hash<long> {
00109   size_t operator()(long __x) const { return __x; }
00110 };
00111 _STLP_TEMPLATE_NULL struct hash<unsigned long> {
00112   size_t operator()(unsigned long __x) const { return __x; }
00113 };
00114 
00115 #if defined (_STLP_LONG_LONG)
00116 _STLP_TEMPLATE_NULL struct hash<_STLP_LONG_LONG> {
00117   size_t operator()(_STLP_LONG_LONG x) const { return (size_t)x; }
00118 };
00119 _STLP_TEMPLATE_NULL struct hash<unsigned _STLP_LONG_LONG> {
00120   size_t operator()(unsigned _STLP_LONG_LONG x) const { return (size_t)x; }
00121 };
00122 #endif
00123 
00124 _STLP_TEMPLATE_NULL
00125 struct hash<void *>
00126 {
00127     union __vp {
00128         size_t s;
00129         void  *p;
00130     };
00131 
00132     size_t operator()(void *__x) const
00133       {
00134         __vp vp;
00135         vp.p = __x;
00136         return vp.s;
00137       }
00138 };
00139 
00140 _STLP_END_NAMESPACE
00141 
00142 #endif /* _STLP_HASH_FUN_H */
00143 
00144 // Local Variables:
00145 // mode:C++
00146 // End:

Generated on Sun May 27 2012 04:29:02 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.