mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Preliminary work on hashing
- Hash returns unsigned - FixedList templated on unsigned int - include uLabel.H in UList, HashTable etc. so the output function is know throughout
This commit is contained in:
@ -85,14 +85,14 @@ public:
|
||||
static const string null;
|
||||
|
||||
|
||||
//- Hashing function class
|
||||
//- Hashing function class, shared by all the derived classes
|
||||
class hash
|
||||
{
|
||||
public:
|
||||
hash()
|
||||
{}
|
||||
|
||||
inline size_type operator()(const string&) const;
|
||||
inline unsigned operator()(const string&) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -196,20 +196,21 @@ inline Foam::string Foam::string::operator()(const size_type n) const
|
||||
}
|
||||
|
||||
|
||||
inline Foam::string::size_type Foam::string::hash::operator()
|
||||
inline unsigned Foam::string::hash::operator()
|
||||
(
|
||||
const string& key
|
||||
) const
|
||||
{
|
||||
register size_type val = 0;
|
||||
const size_type len = key.length();
|
||||
const char *data = key.data();
|
||||
|
||||
for (string::const_iterator iter=key.begin(); iter!=key.end(); ++iter)
|
||||
register unsigned val = 0;
|
||||
for (register size_type i=0; i < len; ++data, ++i)
|
||||
{
|
||||
val = (val << 1) ^ *iter;
|
||||
val = (val << 1) ^ *data;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user