mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
HashTable: Added void operator=(std::initializer_list<Tuple2<Key, T>>)
This commit is contained in:
@ -165,6 +165,16 @@ int main()
|
|||||||
table3.clearStorage();
|
table3.clearStorage();
|
||||||
Info<< table3 << nl;
|
Info<< table3 << nl;
|
||||||
|
|
||||||
|
table1 =
|
||||||
|
{
|
||||||
|
{"aca", 3.0},
|
||||||
|
{"aaw", 6.0},
|
||||||
|
{"acr", 8.0},
|
||||||
|
{"aec", 10.0}
|
||||||
|
};
|
||||||
|
|
||||||
|
Info<< "\ntable1" << table1 << nl;
|
||||||
|
|
||||||
Info<< "\nDone\n";
|
Info<< "\nDone\n";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -563,6 +563,29 @@ void Foam::HashTable<T, Key, Hash>::operator=
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, class Key, class Hash>
|
||||||
|
void Foam::HashTable<T, Key, Hash>::operator=
|
||||||
|
(
|
||||||
|
std::initializer_list<Tuple2<Key, T>> lst
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Could be zero-sized from a previous transfer()
|
||||||
|
if (!tableSize_)
|
||||||
|
{
|
||||||
|
resize(lst.size());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const Tuple2<Key, T>& pair : lst)
|
||||||
|
{
|
||||||
|
insert(pair.first(), pair.second());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
bool Foam::HashTable<T, Key, Hash>::operator==
|
bool Foam::HashTable<T, Key, Hash>::operator==
|
||||||
(
|
(
|
||||||
|
|||||||
@ -213,7 +213,7 @@ public:
|
|||||||
HashTable(const Xfer<HashTable<T, Key, Hash>>&);
|
HashTable(const Xfer<HashTable<T, Key, Hash>>&);
|
||||||
|
|
||||||
//- Construct from an initializer list
|
//- Construct from an initializer list
|
||||||
HashTable(std::initializer_list<Tuple2<Key, T>> lst);
|
HashTable(std::initializer_list<Tuple2<Key, T>>);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
@ -315,6 +315,9 @@ public:
|
|||||||
//- Assignment
|
//- Assignment
|
||||||
void operator=(const HashTable<T, Key, Hash>&);
|
void operator=(const HashTable<T, Key, Hash>&);
|
||||||
|
|
||||||
|
//- Assignment to an initializer list
|
||||||
|
void operator=(std::initializer_list<Tuple2<Key, T>>);
|
||||||
|
|
||||||
//- Equality. Hash tables are equal if the keys and values are equal.
|
//- Equality. Hash tables are equal if the keys and values are equal.
|
||||||
// Independent of table storage size and table order.
|
// Independent of table storage size and table order.
|
||||||
bool operator==(const HashTable<T, Key, Hash>&) const;
|
bool operator==(const HashTable<T, Key, Hash>&) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user