Test-HashTable2.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 Description
25  Miscellaneous tests for HashTable
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "HashTable.H"
30 #include "HashPtrTable.H"
31 #include "Map.H"
32 
33 using namespace Foam;
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 // Main program:
37 
38 int main(int argc, char *argv[])
39 {
41 
42  table1.insert("kjhk", 10);
43  table1.insert("kjhk2", 12);
44 
45  Info<< "table1: " << table1 << nl
46  << "toc: " << table1.toc() << endl;
47 
49 
50  table2.insert(3, 10);
51  table2.insert(5, 12);
52  table2.insert(7, 16);
53 
54  Info<< "table2: " << table2 << nl
55  << "toc: " << table2.toc() << endl;
56 
57  Map<label> table3(1);
58  table3.transfer(table2);
59 
60  Info<< "table2: " << table2 << nl
61  << "toc: " << table2.toc() << endl;
62 
63  Info<< "table3: " << table3 << nl
64  << "toc: " << table3.toc() << endl;
65 
66  Map<label> table4(table3.xfer());
67 
68  Info<< "table3: " << table3 << nl
69  << "toc: " << table3.toc() << endl;
70 
71  Info<< "table4: " << table4 << nl
72  << "toc: " << table4.toc() << endl;
73 
75  ptable1.insert("kjhkjh", new label(10));
76 
77  Info<< "PtrTable toc: " << ptable1.toc() << endl;
78 
79  Info<< "End\n" << endl;
80 
81  return 0;
82 }
83 
84 
85 // ************************************************************************* //
HashTable.H
Foam::HashTable::toc
List< Key > toc() const
Return the table of contents.
Definition: HashTable.C:201
Foam::HashTable::insert
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
Definition: HashTableI.H:80
Foam::Map< label >
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Map.H
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::HashTable
An STL-conforming hash table.
Definition: HashTable.H:61
Foam::HashPtrTable
A HashTable specialization for hashing pointers.
Definition: HashPtrTable.H:50
main
int main(int argc, char *argv[])
Definition: Test-HashTable2.C:38
HashPtrTable.H