Commit c6e9b323 authored by Mark Olesen's avatar Mark Olesen
Browse files

added HashSet::operator[]() const

- can use the same syntax for boolList, PackedBoolList and labelHashSet
    if (myHashedSet[x]) ...
    if (myBoolList[x]) ...
    if (myPackedList[x]) ...
parent c048dd88
......@@ -111,6 +111,33 @@ int main(int argc, char *argv[])
Info<< "setD : " << 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;
}
......
......@@ -51,6 +51,13 @@ Foam::HashSet<Key, Hash>::HashSet(const HashTable<AnyType, Key, Hash>& ht)
// * * * * * * * * * * * * * * * 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>
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());
}
// 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.
// Independent of table size or order.
bool operator==(const HashSet<Key, Hash>&) const;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment