mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: HashTable and HashSet improvements
- unfriend HashSet, HashTable IO operators
- global min(), max(), minMax() functions taking a labelHashSet and an
optional limit. For example,
labelHashSet set = ...;
Info<< "min is " << min(set) << nl;
Info<< "max (non-negative) " << max(set, 0) << nl;
- make HashTable iterator '->' dereferencing more consistent by also
supporting non-pointer types as well.
- read HashTable values in-situ to avoid copying
This commit is contained in:
committed by
Andrew Heather
parent
ca5e7a5224
commit
bbc2d4a8b0
@ -32,6 +32,7 @@ Description
|
||||
#include "HashOps.H"
|
||||
#include "HashSet.H"
|
||||
#include "Map.H"
|
||||
#include "MinMax.H"
|
||||
#include "labelPairHashes.H"
|
||||
#include "FlatOutput.H"
|
||||
|
||||
@ -184,6 +185,9 @@ int main(int argc, char *argv[])
|
||||
1, 11, 42
|
||||
};
|
||||
|
||||
Info<<"Set with min/max:" << minMax(setB)
|
||||
<< " min:" << min(setB) << " max:" << max(setB) << nl;
|
||||
|
||||
setB = FixedList<label, 4>({1, 2, 3, 4});
|
||||
setB = {1, 2, 4};
|
||||
setB = List<label>({1, 2, 4});
|
||||
|
||||
@ -261,14 +261,24 @@ int main(int argc, char *argv[])
|
||||
|
||||
labelList list1(identity(4, -4));
|
||||
|
||||
Info<<"move insert " << list1 << nl;
|
||||
Info<< "move insert " << list1 << nl;
|
||||
|
||||
ltable1.insert("pqr", std::move(list1));
|
||||
|
||||
Info<<"after insert " << list1 << nl;
|
||||
Info<< "after insert " << list1 << nl;
|
||||
|
||||
Info<< nl << "HashTable<labelList>: "
|
||||
<< ltable1 << nl;
|
||||
|
||||
|
||||
// Use '->' dereferencing
|
||||
const auto iter = ltable1.cfind("ghi");
|
||||
|
||||
if (iter)
|
||||
{
|
||||
Info<< "got with " << iter->size() << nl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
Reference in New Issue
Block a user