MCPcopy Create free account
hub / github.com/OpenFOAM/OpenFOAM-dev / main

Function main

applications/test/StaticHashTable/Test-staticHashTable.C:39–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37// Main program:
38
39int main()
40{
41 HASHTABLE_CLASS<double> table1(13);
42
43 table1.insert("aaa", 1.0);
44 table1.insert("aba", 2.0);
45 table1.insert("aca", 3.0);
46 table1.insert("ada", 4.0);
47 table1.insert("aeq", 5.0);
48 table1.insert("aaw", 6.0);
49 table1.insert("abs", 7.0);
50 table1.insert("acr", 8.0);
51 table1.insert("adx", 9.0);
52 table1.insert("aec", 10.0);
53
54 table1.erase("aaw");
55 table1.erase("abs");
56
57 Info<< "\ntable1 toc: " << table1.toc() << endl;
58 table1.printInfo(Info)
59 << "table1 [" << table1.size() << "] " << endl;
60 forAllIter(HASHTABLE_CLASS<double>, table1, iter)
61 {
62 Info<< iter.key() << " => " << iter() << nl;
63 }
64
65 table1.set("acr", 108);
66 table1.set("adx", 109);
67 table1.set("aec", 100);
68 table1("aaw") -= 1000;
69 table1("aeq") += 1000;
70
71 Info<< "\noverwrote some values table1: " << table1 << endl;
72
73 Info<< "\ntest find:" << endl;
74 Info<< table1.find("aaa")() << nl
75 << table1.find("aba")() << nl
76 << table1.find("aca")() << nl
77 << table1.find("ada")() << nl
78 << table1.find("aeq")() << nl
79 << table1.find("acr")() << nl
80 << table1.find("adx")() << nl
81 << table1.find("aec")() << nl
82 << table1["aaa"] << nl;
83
84 {
85 OStringStream os;
86 os << table1;
87 HASHTABLE_CLASS<double> readTable(IStringStream(os.str())(), 100);
88
89 Info<< "Istream constructor:" << readTable << endl;
90 }
91
92
93 HASHTABLE_CLASS<double> table2(table1);
94 HASHTABLE_CLASS<double> table3(table1.xfer());
95
96 Info<< "\ncopy table1 -> table2" << nl

Callers

nothing calls this directly

Calls 13

IStringStreamClass · 0.85
eraseMethod · 0.80
forAllIterFunction · 0.50
insertMethod · 0.45
sizeMethod · 0.45
keyMethod · 0.45
setMethod · 0.45
strMethod · 0.45
xferMethod · 0.45
resizeMethod · 0.45
clearMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected