mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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>
|
||||
|
||||
Reference in New Issue
Block a user