@@ -23,7 +23,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
#pragma once
24
24
25
25
#include < cppcore/CPPCoreCommon.h>
26
- #include < cppcore/Common/CString.h>
27
26
28
27
namespace CPPCore {
29
28
@@ -40,38 +39,32 @@ class Hash {
40
39
41
40
// / @brief The class constructor with a given hash value.
42
41
// / @param hash [in] An integer value to compute the hash from.
43
- explicit Hash ( unsigned int hash );
42
+ explicit Hash (unsigned int hash);
44
43
45
44
// / @brief The class constructor with a given char buffer.
46
45
// / @param value [in] A character buffer to compute the hash from.
47
46
// / @param base [in] The table base.
48
- explicit Hash ( const char *buffer, unsigned int base );
49
-
47
+ explicit Hash (const char *buffer, unsigned int base);
48
+
50
49
// / @brief The class constructor with a given unsigned int value.
51
50
// / @param value [in] An unsigned int value to compute the hash from.
52
51
// / @param base [in] The table base.
53
- explicit Hash ( unsigned int value, unsigned int base );
52
+ explicit Hash (unsigned int value, unsigned int base);
54
53
55
54
// / @brief The class destructor.
56
55
~Hash ();
57
56
58
- // / @brief Computes the hash value for a given string.
59
- // / @param key [in] The string.
60
- // / @param base [in] The table base.
61
- // / @return The hash value.
62
- static unsigned int toHash ( const CString &key, unsigned int base );
63
-
64
57
// / @brief Computes the hash value for a given character buffer.
65
58
// / @param buffer [in] The buffer.
66
59
// / @param base [in] The table base.
67
60
// / @return The hash value.
68
- static unsigned int toHash ( const char *buffer, unsigned int base );
61
+ static unsigned int toHash (const char *buffer, unsigned int base);
69
62
70
63
// / @brief Computes the hash value for a given unsigned int value.
71
64
// / @param buffer [in] The unsigned int value.
72
65
// / @param base [in] The table base.
73
66
// / @return The hash value.
74
- static unsigned int toHash ( unsigned int value, unsigned int base );
67
+ static unsigned int toHash (unsigned int value, unsigned int base);
75
68
76
69
// / brief Returns the stored hash value.
77
70
// / @return The hash value.
@@ -81,64 +74,51 @@ class Hash {
81
74
unsigned int m_hash;
82
75
};
83
76
84
- inline
85
- Hash::Hash ()
86
- : m_hash( 0 ){
77
+ inline Hash::Hash () :
78
+ m_hash(0 ) {
87
79
// empty
88
80
}
89
81
90
- inline
91
- Hash::Hash ( unsigned int hash )
92
- : m_hash( hash ) {
82
+ inline Hash::Hash (unsigned int hash) :
83
+ m_hash(hash) {
93
84
// empty
94
85
}
95
86
96
- inline
97
- Hash::Hash ( const char *buffer, unsigned int base )
98
- : m_hash( Hash::toHash( buffer, base ) ) {
87
+ inline Hash::Hash (const char *buffer, unsigned int base) :
88
+ m_hash(Hash::toHash(buffer, base)) {
99
89
// empty
100
90
}
101
91
102
- inline
103
- Hash::Hash ( unsigned int value, unsigned int base )
104
- : m_hash( Hash::toHash( value, base ) ) {
92
+ inline Hash::Hash (unsigned int value, unsigned int base) :
93
+ m_hash(Hash::toHash(value, base)) {
105
94
// empty
106
95
}
107
96
108
- inline
109
- Hash::~Hash () {
97
+ inline Hash::~Hash () {
110
98
// empty
111
99
}
112
100
113
- inline
114
- unsigned int Hash::toHash ( const CString &key, unsigned int base ) {
115
- return toHash ( key.c_str (), base );
116
- }
117
-
118
- inline
119
- unsigned int Hash::toHash ( const char *buffer, unsigned int base ) {
120
- unsigned int hash ( 0 );
121
- if ( nullptr == buffer ) {
101
+ inline unsigned int Hash::toHash (const char *buffer, unsigned int base) {
102
+ unsigned int hash (0 );
103
+ if (nullptr == buffer) {
122
104
return hash;
123
105
}
124
-
106
+
125
107
// using division-rest method
126
108
// see http://de.wikipedia.org/wiki/Divisionsrestmethode
127
- for ( size_t i = 0 ; i < strlen ( buffer ); ++i ) {
128
- hash = ( hash * 128 + buffer[ i ] ) % base;
109
+ for ( size_t i = 0 ; i < strlen (buffer); ++i) {
110
+ hash = (hash * 128 + buffer[i] ) % base;
129
111
}
130
-
112
+
131
113
return hash;
132
114
}
133
115
134
- inline
135
- unsigned int Hash::toHash ( unsigned int value, unsigned int base ) {
136
- const unsigned int hash ( value % base );
116
+ inline unsigned int Hash::toHash (unsigned int value, unsigned int base) {
117
+ const unsigned int hash (value % base);
137
118
return hash;
138
119
}
139
120
140
- inline
141
- unsigned int Hash::hashValue () const {
121
+ inline unsigned int Hash::hashValue () const {
142
122
return m_hash;
143
123
}
144
124
0 commit comments