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:
Mark Olesen
2009-02-27 12:40:37 +01:00
parent a46c85f5a4
commit 576d9388f0
39 changed files with 159 additions and 134 deletions

View File

@ -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;
};

View File

@ -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;
}
// ************************************************************************* //