HashSet enhancement

- allow insert() and set() from a UList of Key
  This complements the existing erase(const UList<Key>&) method
This commit is contained in:
Mark Olesen
2009-12-01 18:26:18 +01:00
parent d0b8aa40f0
commit a4f4a904f4
3 changed files with 55 additions and 10 deletions

View File

@ -31,6 +31,18 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Key, class Hash>
Foam::HashSet<Key, Hash>::HashSet(const UList<Key>& lst)
:
HashTable<nil, Key, Hash>(2*lst.size())
{
forAll(lst, elemI)
{
insert(lst[elemI]);
}
}
template<class Key, class Hash>
template<class AnyType>
Foam::HashSet<Key, Hash>::HashSet(const HashTable<AnyType, Key, Hash>& h)
@ -49,6 +61,24 @@ Foam::HashSet<Key, Hash>::HashSet(const HashTable<AnyType, Key, Hash>& h)
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Key, class Hash>
Foam::label Foam::HashSet<Key, Hash>::insert(const UList<Key>& lst)
{
label count = 0;
forAll(lst, elemI)
{
if (insert(lst[elemI]))
{
++count;
}
}
return count;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Key, class Hash>