00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 // -------------------------------------------------------------------------- 00005 // OpenMS Mass Spectrometry Framework 00006 // -------------------------------------------------------------------------- 00007 // Copyright (C) 2003-2008 -- Oliver Kohlbacher, Knut Reinert 00008 // 00009 // This library is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU Lesser General Public 00011 // License as published by the Free Software Foundation; either 00012 // version 2.1 of the License, or (at your option) any later version. 00013 // 00014 // This library is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 // Lesser General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU Lesser General Public 00020 // License along with this library; if not, write to the Free Software 00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 // 00023 // -------------------------------------------------------------------------- 00024 // $Maintainer: Oliver Kohlbacher $ 00025 // -------------------------------------------------------------------------- 00026 00027 #ifndef OPENMS_CONCEPT_HASHFUNCTION_H 00028 #define OPENMS_CONCEPT_HASHFUNCTION_H 00029 00030 #include <OpenMS/CONCEPT/Types.h> 00031 #include <OpenMS/DATASTRUCTURES/String.h> 00032 00033 #include <string> 00034 00035 namespace OpenMS 00036 { 00046 template <typename T> 00047 class HashFunction 00048 { 00049 public: 00050 00051 UInt operator () (const T& t) const throw() 00052 { 00053 return Hash(t); 00054 } 00055 }; 00056 00060 00063 extern UInt hashPointer(void *const ptr) throw(); 00064 00067 extern UInt hashString(const char* str) throw(); 00068 00071 extern UInt hashPJWString(const char* str) throw(); 00072 00075 extern UInt hashElfString(const char* str) throw(); 00076 00084 template <typename T> 00085 inline UInt Hash(const T& key) throw() 00086 { 00087 return static_cast<UInt>((OPENMS_POINTERSIZEINT_TYPE)key); 00088 } 00089 00094 inline UInt Hash(const String& s) throw() 00095 { 00096 return hashString(s.c_str()); 00097 } 00098 00103 inline UInt Hash(const std::string& s) throw() 00104 { 00105 return hashString(s.c_str()); 00106 } 00107 00111 inline UInt Hash(void* const& ptr) throw() 00112 { 00113 return hashPointer(ptr); 00114 } 00115 00117 00119 00124 UInt getNextPrime(UInt l) throw(); 00125 00127 00128 } // namespace OPENMS 00129 00130 #endif // OPENMS_CONCEPT_HASHFUNCTION_H
Generated Tue Apr 1 15:36:34 2008 -- using doxygen 1.5.4 | OpenMS / TOPP 1.1 |