Back to index

salome-med  6.5.0
InterpKernelHashFun.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009 Free Software Foundation, Inc.
00002 //
00003 // This file is part of the GNU ISO C++ Library.  This library is free
00004 // software; you can redistribute it and/or modify it under the
00005 // terms of the GNU General Public License as published by the
00006 // Free Software Foundation; either version 3, or (at your option)
00007 // any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 
00014 // Under Section 7 of GPL version 3, you are granted additional
00015 // permissions described in the GCC Runtime Library Exception, version
00016 // 3.1, as published by the Free Software Foundation.
00017 
00018 // You should have received a copy of the GNU General Public License and
00019 // a copy of the GCC Runtime Library Exception along with this program;
00020 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00021 // <http://www.gnu.org/licenses/>.
00022 
00023 /*
00024  * Copyright (c) 1996-1998
00025  * Silicon Graphics Computer Systems, Inc.
00026  *
00027  * Permission to use, copy, modify, distribute and sell this software
00028  * and its documentation for any purpose is hereby granted without fee,
00029  * provided that the above copyright notice appear in all copies and
00030  * that both that copyright notice and this permission notice appear
00031  * in supporting documentation.  Silicon Graphics makes no
00032  * representations about the suitability of this software for any
00033  * purpose.  It is provided "as is" without express or implied warranty.
00034  *
00035  *
00036  * Copyright (c) 1994
00037  * Hewlett-Packard Company
00038  *
00039  * Permission to use, copy, modify, distribute and sell this software
00040  * and its documentation for any purpose is hereby granted without fee,
00041  * provided that the above copyright notice appear in all copies and
00042  * that both that copyright notice and this permission notice appear
00043  * in supporting documentation.  Hewlett-Packard Company makes no
00044  * representations about the suitability of this software for any
00045  * purpose.  It is provided "as is" without express or implied warranty.
00046  *
00047  */
00048 #ifndef __INTERPKERNELHASHFUN_HXX__
00049 #define __INTERPKERNELHASHFUN_HXX__
00050 
00051 #include <cstddef>
00052 
00053 namespace INTERP_KERNEL
00054 {
00055   template<class _Key>
00056   struct hash { };
00057 
00058   inline std::size_t __stl_hash_string(const char* __s)
00059   {
00060     unsigned long __h = 0;
00061     for ( ; *__s; ++__s)
00062       __h = 5 * __h + *__s;
00063     return std::size_t(__h);
00064   }
00065 
00066   template<>
00067   struct hash<char*>
00068   {
00069     std::size_t operator()(const char* __s) const
00070     { return __stl_hash_string(__s); }
00071   };
00072 
00073   template<>
00074   struct hash<const char*>
00075   {
00076     std::size_t operator()(const char* __s) const
00077     { return __stl_hash_string(__s); }
00078   };
00079 
00080   template<>
00081   struct hash<char>
00082   { 
00083     std::size_t operator()(char __x) const { return __x; }
00084   };
00085 
00086   template<>
00087   struct hash<unsigned char>
00088   { 
00089     std::size_t operator()(unsigned char __x) const { return __x; }
00090   };
00091 
00092   template<>
00093   struct hash<signed char>
00094   {
00095     std::size_t operator()(unsigned char __x) const { return __x; }
00096   };
00097 
00098   template<>
00099   struct hash<short>
00100   {
00101     std::size_t operator()(short __x) const { return __x; }
00102   };
00103 
00104   template<>
00105   struct hash<unsigned short>
00106   {
00107     std::size_t operator()(unsigned short __x) const { return __x; }
00108   };
00109 
00110   template<>
00111   struct hash<int>
00112   { 
00113     std::size_t operator()(int __x) const { return __x; }
00114   };
00115 
00116   template<>
00117   struct hash<unsigned int>
00118   { 
00119     std::size_t operator()(unsigned int __x) const { return __x; }
00120   };
00121 
00122   template<>
00123   struct hash<long>
00124   {
00125     std::size_t operator()(long __x) const { return __x; }
00126   };
00127 
00128   template<>
00129   struct hash<unsigned long>
00130   {
00131     std::size_t operator()(unsigned long __x) const { return __x; }
00132   };
00133 }
00134 
00135 #endif