containers: added methods contains(), remove(), replace(), replaceOrAdd(),

corresponding to contains(), removeIf(), replaceIf(), and replaceOrAdd(), but overloaded for const T& as well as for predicates.
refs #106
This commit is contained in:
Mathew Sutcliffe
2014-01-25 19:26:57 +00:00
parent 33d555e151
commit 6f19d0a479
2 changed files with 35 additions and 0 deletions

View File

@@ -94,6 +94,16 @@ namespace BlackMisc
return std::any_of(derived().begin(), derived().end(), p);
}
/*!
* \brief Return true if there is an element equal to given object
* \param object is this object in container?
* \return
*/
bool contains(const T &object) const
{
return std::find(derived().begin(), derived().end(), object) != derived().end();
}
/*!
* \brief Return a copy containing only those elements matching a particular key/value pair.
* \param key1 A pointer to a member function of T.