From 5388a95da295216e038fe8162d55d491d67c2113 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Fri, 22 Jun 2012 16:57:35 +0100
Subject: [PATCH] ENH: Hash: template specialisation for Hash<string> and
 derivatives

---
 src/OpenFOAM/primitives/hashes/Hash/Hash.H | 105 ++++++++++++++++++++-
 1 file changed, 104 insertions(+), 1 deletion(-)

diff --git a/src/OpenFOAM/primitives/hashes/Hash/Hash.H b/src/OpenFOAM/primitives/hashes/Hash/Hash.H
index e5fbb2823be..e4f67371da3 100644
--- a/src/OpenFOAM/primitives/hashes/Hash/Hash.H
+++ b/src/OpenFOAM/primitives/hashes/Hash/Hash.H
@@ -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.
-- 
GitLab