mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
added HashSet::operator[]() const
- can use the same syntax for boolList, PackedBoolList and labelHashSet
if (myHashedSet[x]) ...
if (myBoolList[x]) ...
if (myPackedList[x]) ...
This commit is contained in:
@ -111,6 +111,33 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "setD : " << setD << endl;
|
Info<< "setD : " << setD << endl;
|
||||||
Info<< "setB ^ setC ^ setD : " << (setB ^ setC ^ setD) << endl;
|
Info<< "setB ^ setC ^ setD : " << (setB ^ setC ^ setD) << endl;
|
||||||
|
|
||||||
|
// test operator[]
|
||||||
|
|
||||||
|
Info<< "setD : " << setD << endl;
|
||||||
|
if (setD[0])
|
||||||
|
{
|
||||||
|
Info<< "setD has 0" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "setD has no 0" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (setD[11])
|
||||||
|
{
|
||||||
|
Info<< "setD has 11" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "setD has no 0" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "setD : " << setD << endl;
|
||||||
|
|
||||||
|
// this doesn't work (yet?)
|
||||||
|
// setD[12] = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,6 +51,13 @@ Foam::HashSet<Key, Hash>::HashSet(const HashTable<AnyType, Key, Hash>& ht)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Key, class Hash>
|
||||||
|
inline bool Foam::HashSet<Key, Hash>::operator[](const Key& key) const
|
||||||
|
{
|
||||||
|
return found(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Key, class Hash>
|
template<class Key, class Hash>
|
||||||
bool Foam::HashSet<Key, Hash>::operator==(const HashSet<Key, Hash>& rhs) const
|
bool Foam::HashSet<Key, Hash>::operator==(const HashSet<Key, Hash>& rhs) const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -133,9 +133,11 @@ public:
|
|||||||
return HashTable<nil, Key, Hash>::insert(key, nil());
|
return HashTable<nil, Key, Hash>::insert(key, nil());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
|
//- Return true if the entry exists, same as found()
|
||||||
|
inline bool operator[](const Key&) const;
|
||||||
|
|
||||||
//- Equality. Two hashtables are equal when their contents are equal.
|
//- Equality. Two hashtables are equal when their contents are equal.
|
||||||
// Independent of table size or order.
|
// Independent of table size or order.
|
||||||
bool operator==(const HashSet<Key, Hash>&) const;
|
bool operator==(const HashSet<Key, Hash>&) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user