diff --git a/src/blackmisc/containerbase.h b/src/blackmisc/containerbase.h index e4fd13c30..5900781f6 100644 --- a/src/blackmisc/containerbase.h +++ b/src/blackmisc/containerbase.h @@ -72,42 +72,15 @@ namespace BlackMisc } /*! - * \brief Return a copy containing only those 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. + * \brief Return a copy containing only those elements matching some particular key/value pair(s). + * \param k0 A pointer to a member function of T. + * \param v0 A value to compare against the value returned by k0. + * \param keysValues Zero or more additional pairs of { pointer to member function of T, value to compare it against }. */ - template - C findBy(K1 key1, V1 value1) const + template + C findBy(K0 k0, V0 v0, KeysValues... keysValues) const { - return findBy(BlackMisc::Predicates::MemberEqual(key1, value1)); - } - - /*! - * \brief Return a copy containing only those elements matching some particular key/value pairs. - * \param key1 A pointer to a member function of T. - * \param value1 Will be compared to the return value of key1. - * \param key2 A pointer to a member function of T. - * \param value2 Will be compared to the return value of key2. - */ - template - C findBy(K1 key1, V1 value1, K2 key2, V2 value2) const - { - return findBy(BlackMisc::Predicates::MemberEqual(key1, value1, key2, value2)); - } - - /*! - * \brief Return a copy containing only those elements matching some particular key/value pairs. - * \param key1 A pointer to a member function of T. - * \param value1 Will be compared to the return value of key1. - * \param key2 A pointer to a member function of T. - * \param value2 Will be compared to the return value of key2. - * \param key3 A pointer to a member function of T. - * \param value3 Will be compared to the return value of key3. - */ - template - C findBy(K1 key1, V1 value1, K2 key2, V2 value2, K3 key3, V3 value3) const - { - return findBy(BlackMisc::Predicates::MemberEqual(key1, value1, key2, value2, key3, value3)); + return findBy(BlackMisc::Predicates::MemberEqual(k0, v0, keysValues...)); } /*! @@ -136,14 +109,15 @@ namespace BlackMisc } /*! - * \brief Return a copy containing only those 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. + * \brief Return a copy containing only those elements matching some particular key/value pair(s). + * \param k0 A pointer to a member function of T. + * \param v0 A value to compare against the value returned by k0. + * \param keysValues Zero or more additional pairs of { pointer to member function of T, value to compare it against }. */ - template - bool contains(K1 key1, V1 value1) const + template + bool contains(K0 k0, V0 v0, KeysValues... keysValues) const { - return contains(BlackMisc::Predicates::MemberEqual(key1, value1)); + return contains(BlackMisc::Predicates::MemberEqual(k0, v0, keysValues...)); } /*! @@ -161,14 +135,15 @@ namespace BlackMisc } /*! - * \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. + * \brief Remove elements matching some particular key/value pair(s). + * \param k0 A pointer to a member function of T. + * \param v0 A value to compare against the value returned by k0. + * \param keysValues Zero or more additional pairs of { pointer to member function of T, value to compare it against }. */ - template - void removeIf(K1 key1, V1 value1) + template + void removeIf(K0 k0, V0 v0, KeysValues... keysValues) { - removeIf(BlackMisc::Predicates::MemberEqual(key1, value1)); + removeIf(BlackMisc::Predicates::MemberEqual(k0, v0, keysValues...)); } public: diff --git a/src/blackmisc/sequence.h b/src/blackmisc/sequence.h index afa893758..9be92b791 100644 --- a/src/blackmisc/sequence.h +++ b/src/blackmisc/sequence.h @@ -401,33 +401,13 @@ namespace BlackMisc } /*! - * \brief In-place sort by a particular key. + * \brief In-place sort by some particular key(s). * \param key1 A pointer to a member function of T. + * \param keys Zero or more additional pointers to member functions of T. */ - template void sortBy(K1 key1) + template void sortBy(K1 key1, Keys... keys) { - sort(BlackMisc::Predicates::MemberLess(key1)); - } - - /*! - * \brief In-place sort by some particular keys. - * \param key1 A pointer to a member function of T. - * \param key2 A pointer to a member function of T. - */ - template void sortBy(K1 key1, K2 key2) - { - sort(BlackMisc::Predicates::MemberLess(key1, key2)); - } - - /*! - * \brief In-place sort by some particular keys. - * \param key1 A pointer to a member function of T. - * \param key2 A pointer to a member function of T. - * \param key3 A pointer to a member function of T. - */ - template void sortBy(K1 key1, K2 key2, K3 key3) - { - sort(BlackMisc::Predicates::MemberLess(key1, key2, key3)); + sort(BlackMisc::Predicates::MemberLess(key1, keys...)); } /*! @@ -442,36 +422,14 @@ namespace BlackMisc } /*! - * \brief Return a copy sorted by a particular key. + * \brief Return a copy sorted by some particular key(s). * \param key1 A pointer to a member function of T. + * \param keys Zero or more additional pointers to member functions of T. */ - template - CSequence sortedBy(K1 key1) const + template + CSequence sortedBy(K1 key1, Keys... keys) const { - return sorted(BlackMisc::Predicates::MemberLess(key1)); - } - - /*! - * \brief Return a copy sorted by some particular keys. - * \param key1 A pointer to a member function of T. - * \param key2 A pointer to a member function of T. - */ - template - CSequence sortedBy(K1 key1, K2 key2) const - { - return sorted(BlackMisc::Predicates::MemberLess(key1, key2)); - } - - /*! - * \brief Return a copy sorted by some particular keys. - * \param key1 A pointer to a member function of T. - * \param key2 A pointer to a member function of T. - * \param key3 A pointer to a member function of T. - */ - template - CSequence sortedBy(K1 key1, K2 key2, K3 key3) const - { - return sorted(BlackMisc::Predicates::MemberLess(key1, key2, key3)); + return sorted(BlackMisc::Predicates::MemberLess(key1, keys...)); } /*!