diff --git a/applications/test/HashTable/hashTableTest.C b/applications/test/HashTable/hashTableTest.C index 7e03a36f7d..d0eae87243 100644 --- a/applications/test/HashTable/hashTableTest.C +++ b/applications/test/HashTable/hashTableTest.C @@ -40,6 +40,7 @@ using namespace Foam; int main() { HASHTABLE_CLASS table1(13); + HASHTABLE_CLASS::iterator iter; table1.insert("aaa", 1.0); table1.insert("aba", 2.0); @@ -52,8 +53,12 @@ int main() table1.insert("adx", 9.0); table1.insert("aec", 10.0); + // erase by key table1.erase("aaw"); - table1.erase("abs"); + + // erase by iterator + iter = table1.find("abs"); + table1.erase(iter); Info<< "\ntable1 toc: " << table1.toc() << endl; Info<< "\ntable1 sortedToc: " << table1.sortedToc() << endl; diff --git a/applications/test/HashTable3/Make/files b/applications/test/HashTable3/Make/files new file mode 100644 index 0000000000..e8ec193ffa --- /dev/null +++ b/applications/test/HashTable3/Make/files @@ -0,0 +1,3 @@ +hashTableTest3.C + +EXE = $(FOAM_USER_APPBIN)/hashTableTest3 diff --git a/applications/test/HashTable3/Make/options b/applications/test/HashTable3/Make/options new file mode 100644 index 0000000000..6a9e9810b3 --- /dev/null +++ b/applications/test/HashTable3/Make/options @@ -0,0 +1,2 @@ +/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */ +/* EXE_LIBS = -lfiniteVolume */ diff --git a/applications/test/HashTable3/hashTableTest3.C b/applications/test/HashTable3/hashTableTest3.C new file mode 100644 index 0000000000..910e4f2290 --- /dev/null +++ b/applications/test/HashTable3/hashTableTest3.C @@ -0,0 +1,87 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + + Test speeds for some HashTable operations + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "HashTable.H" +#include "HashPtrTable.H" +#include "Map.H" +#include "StaticHashTable.H" +#include "HashTbl.H" +#include "cpuTime.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + const label nLoops = 30; + const label nBase = 100000; + const label nSize = nLoops * nBase; + + cpuTime timer; + + // ie, a + // Map