Commit 5388a95d authored by mattijs's avatar mattijs
Browse files

ENH: Hash: template specialisation for Hash<string> and derivatives

parent 3a3bd932
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -37,6 +37,8 @@ Description
#include "uLabel.H"
#include "Hasher.H"
#include "pTraits.H"
#include "fileName.H"
#include "wordRe.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -99,6 +101,107 @@ public:
};
//- Hash specialization for hashing strings
template<>
class Hash<Foam::string>
{
public:
Hash()
{}
unsigned operator()(const string& p, unsigned seed) const
{
return string::hash()(p, seed);
}
unsigned operator()(const string& p) const
{
return string::hash()(p);
}
};
//- Hash specialization for hashing words
template<>
class Hash<Foam::word>
{
public:
Hash()
{}
unsigned operator()(const word& p, unsigned seed) const
{
return word::hash()(p, seed);
}
unsigned operator()(const word& p) const
{
return word::hash()(p);
}
};
//- Hash specialization for hashing fileNames
template<>
class Hash<Foam::fileName>
{
public:
Hash()
{}
unsigned operator()(const fileName& p, unsigned seed) const
{
return fileName::hash()(p, seed);
}
unsigned operator()(const fileName& p) const
{
return fileName::hash()(p);
}
};
//- Hash specialization for hashing wordRes
template<>
class Hash<Foam::wordRe>
{
public:
Hash()
{}
unsigned operator()(const wordRe& p, unsigned seed) const
{
return wordRe::hash()(p, seed);
}
unsigned operator()(const wordRe& p) const
{
return wordRe::hash()(p);
}
};
//- Hash specialization for hashing keyTypes
template<>
class Hash<Foam::keyType>
{
public:
Hash()
{}
unsigned operator()(const keyType& p, unsigned seed) const
{
return keyType::hash()(p, seed);
}
unsigned operator()(const keyType& p) const
{
return keyType::hash()(p);
}
};
//- Hash specialization for hashing pointer addresses.
// Treat a pointer like a long.
// This should work for both 32-bit and 64-bit pointers.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment