1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
29 \*---------------------------------------------------------------------------*/
31 #include "IOstreams.H"
35 #include "stringList.H"
36 #include "labelList.H"
37 #include "labelPair.H"
39 #include "triFaceList.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 int main(int argc, char *argv[])
50 IFstream is("hashingTests");
55 const word listType(is);
58 IOobject::writeDivider(Info) << listType << endl;
60 if (listType == "stringList")
62 Info<< "contiguous = " << contiguous<string>() << endl << endl;
68 unsigned hash1 = string::hash()(lst[i]);
70 Info<< hex << hash1 << ": " << lst[i] << endl;
74 else if (listType == "labelList")
76 Info<<"contiguous = " << contiguous<label>() << endl << endl;
83 unsigned hash1 = Hash<label>()(lst[i]);
86 unsigned hash2 = Hash<label>()(lst[i], 0);
89 << " (seeded: " << hash2 << ")"
90 << ": " << dec << lst[i] << endl;
93 if (contiguous<label>())
95 unsigned hash3 = Hasher
98 lst.size() * sizeof(label)
101 Info<<"contiguous hashed value " << hex << hash3 << endl;
104 else if (listType == "labelListList")
106 List< List<label> > lst(is);
110 unsigned hash1 = Hasher
113 lst[i].size() * sizeof(label)
117 << ": " << dec << lst[i] << endl;
121 else if (listType == "edgeList")
123 Info<<"contiguous = " << contiguous<edge>() << endl << endl;
129 unsigned hash1 = Hash<edge>()(lst[i]);
132 unsigned hash2 = labelPair::Hash<>()(lst[i]);
134 Info<< hex << hash1 << " (as FixedList: " << hash2
135 << "): " << dec << lst[i] << endl;
138 else if (listType == "triFaceList")
140 Info<<"contiguous = " << contiguous<triFace>() << endl << endl;
147 unsigned hash1 = Hash<triFace>()(lst[i]);
148 unsigned hash2 = FixedList<label, 3>::Hash<>()(lst[i]);
150 Info<< hex << hash1 << " (as FixedList: " << hash2
151 << "): " << dec << lst[i] << endl;
156 Info<< "unknown type: " << listType << endl;
165 // ************************************************************************* //