source: trunk/src/lol/base/hash.h @ 2776

Last change on this file since 2776 was 2776, checked in by benlitz, 7 years ago

base: map methods can now take any type of object that is equatable to the key type and can be hashed by the key type specialization of the Hash class (and added string/char const* compatibility)

  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://www.wtfpl.net/ for more details.
9//
10
11//
12// The Hash class
13// --------------
14// A very simple Hash class.
15//
16
17#if !defined __LOL_BASE_HASH_H__
18#define __LOL_BASE_HASH_H__
19
20namespace lol
21{
22
23template<typename T> class Hash;
24
25template<> class Hash<int8_t>   { public: uint32_t operator()(int8_t) const; };
26template<> class Hash<uint8_t>  { public: uint32_t operator()(uint8_t) const; };
27template<> class Hash<int16_t>  { public: uint32_t operator()(int16_t) const; };
28template<> class Hash<uint16_t> { public: uint32_t operator()(uint16_t) const; };
29template<> class Hash<int32_t>  { public: uint32_t operator()(int32_t) const; };
30template<> class Hash<uint32_t> { public: uint32_t operator()(uint32_t) const; };
31template<> class Hash<int64_t>  { public: uint32_t operator()(int64_t) const; };
32template<> class Hash<uint64_t> { public: uint32_t operator()(uint64_t) const; };
33
34template<> class Hash<half>     { public: uint32_t operator()(half) const; };
35template<> class Hash<float>    { public: uint32_t operator()(float) const; };
36template<> class Hash<double>   { public: uint32_t operator()(double) const; };
37template<> class Hash<ldouble>  { public: uint32_t operator()(ldouble) const; };
38
39template<> class Hash<char const *>
40{
41public:
42    uint32_t operator()(char const *x) const;
43    uint32_t operator()(String const &s) const;
44};
45
46template<> class Hash<String>
47{
48public:
49    uint32_t operator()(String const &s) const;
50    uint32_t operator()(char const *x) const;
51};
52
53} /* namespace lol */
54
55#endif // __LOL_BASE_HASH_H__
56
Note: See TracBrowser for help on using the repository browser.