From bcabe827f648ce95ec831d28df76c429faefead3 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 6 Mar 2018 11:41:34 +0100 Subject: [PATCH] ENH: dedicated HashSetOps, HashTableOps namespaces - relocated HashSetPlusEqOp and HashTablePlusEqOp to HashSetOps::plusEqOp and HashTableOps::plusEqOp, respectively - additional functions for converting between a labelHashSet and a PackedBoolList or List: From lists selections to labelHashSet indices: HashSetOps::used(const PackedBoolList&); HashSetOps::used(const UList&); From labelHashSet to list forms: PackedBoolList bitset(const labelHashSet&); List bools(const labelHashSet&); --- applications/test/HashSet/Test-hashSet.C | 56 ++++++- applications/test/List/Test-List.C | 33 ++-- .../foamToEnsight/findCloudFields.H | 2 +- .../foamToEnsight/foamToEnsight.C | 2 +- .../dataConversion/foamToVTK/findClouds.H | 2 +- .../dataConversion/foamToVTK/foamToVTK.C | 4 +- src/OpenFOAM/Make/files | 1 + .../containers/HashTables/HashOps/HashOps.C | 122 ++++++++++++++ .../containers/HashTables/HashOps/HashOps.H | 151 ++++++++++++++++++ .../HashTables/HashTableOps/HashTableOps.H | 79 --------- 10 files changed, 340 insertions(+), 112 deletions(-) create mode 100644 src/OpenFOAM/containers/HashTables/HashOps/HashOps.C create mode 100644 src/OpenFOAM/containers/HashTables/HashOps/HashOps.H delete mode 100644 src/OpenFOAM/containers/HashTables/HashTableOps/HashTableOps.H diff --git a/applications/test/HashSet/Test-hashSet.C b/applications/test/HashSet/Test-hashSet.C index 425320bc39..eeae7ff0d0 100644 --- a/applications/test/HashSet/Test-hashSet.C +++ b/applications/test/HashSet/Test-hashSet.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,13 +27,50 @@ Description #include "hashedWordList.H" #include "nil.H" +#include "HashOps.H" #include "HashSet.H" #include "Map.H" #include "labelPairHashes.H" #include "FlatOutput.H" +#include + using namespace Foam; +template +void printIf(const Iter& iter) +{ + if (iter.found()) + { + Info<< *iter; + } + else + { + Info<<"(null)"; + } +} + + +template +void printMinMax(const HashSet& set) +{ + const auto first = set.cbegin(); + const auto last = set.cend(); + + const auto min = std::min_element(first, last); + const auto max = std::max_element(first, last); + + Info<< "set: " << flatOutput(set) << nl; + Info<< " min="; + printIf(min); + Info<< nl; + + Info<< " max="; + printIf(max); + Info<< nl; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: @@ -131,9 +168,14 @@ int main(int argc, char *argv[]) Info<< "create from Map