BALL 1.5.0
hash.h
Go to the documentation of this file.
1// -*- Mode: C++; tab-width: 2; -*-
2// vi: set ts=2:
3//
4
5#ifndef BALL_COMMON_HASH_H
6#define BALL_COMMON_HASH_H
7
8#ifndef BALL_COMMON_H
9# include <BALL/common.h>
10#endif
11
12#ifndef BALL_DATATYPE_STRING_H
13# include <BALL/DATATYPE/string.h>
14#endif
15
16namespace BALL
17{
21
24 BALL_EXPORT extern HashIndex hashPointer(void *const ptr);
25
28 BALL_EXPORT extern HashIndex hashString(const char* str);
29
32 BALL_EXPORT extern HashIndex hashPJWString(const char* str);
33
36 BALL_EXPORT extern HashIndex hashElfString(const char* str);
37
46 template <typename T>
47 inline HashIndex Hash(const T& key)
48 {
49 return static_cast<HashIndex>((PointerSizeUInt)key);
50 }
51
56 BALL_EXPORT inline HashIndex Hash(const string& s)
57 {
58 return hashString(s.c_str());
59 }
60
66 {
67 return hashString(s.c_str());
68 }
69
73 BALL_EXPORT inline HashIndex Hash(void *const& ptr)
74 {
75 return hashPointer(ptr);
76 }
77
79
81
87
89
90} // namespace BALL
91
92#endif // BALL_COMMON_HASH_H
Definition: constants.h:13
BALL_EXPORT HashIndex hashPointer(void *const ptr)
BALL_POINTERSIZEUINT_TYPE PointerSizeUInt
BALL_EXPORT HashIndex hashPJWString(const char *str)
HashIndex Hash(const T &key)
Definition: hash.h:47
BALL_EXPORT HashIndex hashElfString(const char *str)
BALL_EXPORT HashIndex getNextPrime(HashIndex l)
BALL_EXPORT HashIndex hashString(const char *str)
const char * c_str() const BALL_NOEXCEPT
#define BALL_EXPORT
Definition: COMMON/global.h:50