moved removeIf from CContainerBase to CSequence because it can't work with non-sequential containers, fixes #106

This commit is contained in:
Mathew Sutcliffe
2014-01-25 19:09:58 +00:00
parent 3d3a43602f
commit 33d555e151
2 changed files with 20 additions and 20 deletions

View File

@@ -105,26 +105,6 @@ namespace BlackMisc
return contains(BlackMisc::Predicates::MemberEqual<T>(key1, value1));
}
/*!
* \brief Remove elements for which a given predicate returns true.
*/
template <class Predicate>
void removeIf(Predicate p)
{
std::remove_if(derived().begin(), derived().end(), p);
}
/*!
* \brief Remove elements matching a particular key/value pair.
* \param key1 A pointer to a member function of T.
* \param value1 Will be compared to the return value of key1.
*/
template <class K1, class V1>
void removeIf(K1 key1, V1 value1)
{
removeIf(BlackMisc::Predicates::MemberEqual<T>(key1, value1));
}
public: // CValueObject overrides
/*!
* \copydoc CValueObject::toQVariant()

View File

@@ -247,6 +247,26 @@ namespace BlackMisc
applyIf([ & ](const T &value) { return value == pattern; }, newValues);
}
/*!
* \brief Remove elements for which a given predicate returns true.
*/
template <class Predicate>
void removeIf(Predicate p)
{
std::remove_if(begin(), end(), p);
}
/*!
* \brief Remove elements matching a particular key/value pair.
* \param key1 A pointer to a member function of T.
* \param value1 Will be compared to the return value of key1.
*/
template <class K1, class V1>
void removeIf(K1 key1, V1 value1)
{
removeIf(BlackMisc::Predicates::MemberEqual<T>(key1, value1));
}
/*!
* \brief Replace elements for which a given predicate returns true.
*/