The Original CHomP Software
inthash.h
Go to the documentation of this file.
1
3
14
15// Copyright (C) 1997-2020 by Pawel Pilarczyk.
16//
17// This file is part of my research software package. This is free software:
18// you can redistribute it and/or modify it under the terms of the GNU
19// General Public License as published by the Free Software Foundation,
20// either version 3 of the License, or (at your option) any later version.
21//
22// This software is distributed in the hope that it will be useful,
23// but WITHOUT ANY WARRANTY; without even the implied warranty of
24// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25// GNU General Public License for more details.
26//
27// You should have received a copy of the GNU General Public License
28// along with this software; see the file "license.txt". If not,
29// please, see <https://www.gnu.org/licenses/>.
30
31// Started in January 2002. Last revision: October 24, 2013.
32
33
34#ifndef _CHOMP_STRUCT_INTHASH_H_
35#define _CHOMP_STRUCT_INTHASH_H_
36
37
38//namespace chomp {
39//namespace homology {
40
41// --------------------------------------------------
42// ------------- hash keys for integers -------------
43// --------------------------------------------------
44
46inline int_t hashkey1 (const unsigned long &number)
47{
48 return static_cast<int_t> (number);
49} /* hashkey1 */
50
52inline int_t hashkey2 (const unsigned long &number)
53{
54 return static_cast<int_t> (number ^ 0xFA5A75A7ul) << 8;
55} /* hashkey2 */
56
61#define DEFHASHKEYS(type) \
62inline int_t hashkey1 (const type &number) \
63{ return hashkey1 (static_cast<unsigned long> (number)); } \
64inline int_t hashkey2 (const type &number) \
65{ return hashkey2 (static_cast<unsigned long> (number)); }
66
67DEFHASHKEYS(unsigned int)
68DEFHASHKEYS(signed int)
69//DEFHASHKEYS(unsigned long)
70DEFHASHKEYS(signed long)
71DEFHASHKEYS(unsigned short)
72DEFHASHKEYS(signed short)
73DEFHASHKEYS(unsigned char)
74DEFHASHKEYS(signed char)
75
76#undef DEFHASHKEYS
77
81//template <class T>
82//inline int_t hashkey1 (const T &x)
83//{
84// return x. hashkey1 ();
85//}
86
90//template <class T>
91//inline int_t hashkey2 (const T &x)
92//{
93// return x. hashkey2 ();
94//}
95
96//} // namespace homology
97//} // namespace chomp
98
99#endif // _CHOMP_STRUCT_INTHASH_H_
100
102
#define DEFHASHKEYS(type)
This macro is used to define a hash key for any type that can be cast onto an unsigned inteter type,...
Definition: inthash.h:61
int_t hashkey2(const unsigned long &number)
The second hash key for an unsigned int number.
Definition: inthash.h:52
int_t hashkey1(const unsigned long &number)
The first hash key for an unsigned int number.
Definition: inthash.h:46
int int_t
Index type for indexing arrays, counting cubes, etc.
Definition: config.h:115