/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . Description Miscellaneous tests for HashTable \*---------------------------------------------------------------------------*/ #include "HashTable.H" #include "HashPtrTable.H" #include "Map.H" #include "FlatOutput.H" using namespace Foam; // Simple wrapper for testing purposes class Label { label data_; public: Label() : data_(0) {} Label(label val) : data_(val) {} ~Label() { Info<<"delete label: " << data_ << endl; } // Some arbitrary non-const method (for testing) label increment() { return ++data_; } // Some arbitrary method (for testing) std::string info() const { return "boxed label=" + std::to_string(data_); } friend Ostream& operator<<(Ostream& os, const Label& val) { os << val.data_; return os; } }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: int main(int argc, char *argv[]) { HashTable table1 { {"kjhk", 10}, {"kjhk2", 12} }; Info<< "table1: " << table1 << nl << "toc: " << flatOutput(table1.toc()) << nl; HashTable> table2 { {3, 10}, {5, 12}, {7, 16} }; Info<< "table2: " << table2 << nl << "toc: " << flatOutput(table2.toc()) << nl; Map