added sortedToc()

This commit is contained in:
andy
2009-08-06 17:43:39 +01:00
parent df37b6b431
commit 85f11fa7cc
3 changed files with 14 additions and 1 deletions

View File

@ -56,6 +56,7 @@ int main()
table1.erase("abs"); table1.erase("abs");
Info<< "\ntable1 toc: " << table1.toc() << endl; Info<< "\ntable1 toc: " << table1.toc() << endl;
Info<< "\ntable1 sortedToc: " << table1.sortedToc() << endl;
table1.printInfo(Info) table1.printInfo(Info)
<< "table1 [" << table1.size() << "] " << endl; << "table1 [" << table1.size() << "] " << endl;
forAllIter(HASHTABLE_CLASS<double>, table1, iter) forAllIter(HASHTABLE_CLASS<double>, table1, iter)

View File

@ -231,7 +231,6 @@ Foam::HashTable<T, Key, Hash>::find
} }
// Return the table of contents
template<class T, class Key, class Hash> template<class T, class Key, class Hash>
Foam::List<Key> Foam::HashTable<T, Key, Hash>::toc() const Foam::List<Key> Foam::HashTable<T, Key, Hash>::toc() const
{ {
@ -247,6 +246,16 @@ Foam::List<Key> Foam::HashTable<T, Key, Hash>::toc() const
} }
template<class T, class Key, class Hash>
Foam::List<Key> Foam::HashTable<T, Key, Hash>::sortedToc() const
{
List<Key> sortedList = this->toc();
sort(sortedList);
return sortedList;
}
template<class T, class Key, class Hash> template<class T, class Key, class Hash>
bool Foam::HashTable<T, Key, Hash>::set bool Foam::HashTable<T, Key, Hash>::set
( (

View File

@ -198,6 +198,9 @@ public:
//- Return the table of contents //- Return the table of contents
List<Key> toc() const; List<Key> toc() const;
//- Return the table of contents as a sorted list
List<Key> sortedToc() const;
//- Print information //- Print information
Ostream& printInfo(Ostream&) const; Ostream& printInfo(Ostream&) const;