From b4aa3e86feaebbbd7c289597a0f30f81a295d751 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Sun, 13 Oct 2019 22:00:16 +0200 Subject: [PATCH] override equal_range in ext set --- alib2std/src/extensions/container/set.hpp | 48 +++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/alib2std/src/extensions/container/set.hpp b/alib2std/src/extensions/container/set.hpp index b94a10c733..469ead9170 100644 --- a/alib2std/src/extensions/container/set.hpp +++ b/alib2std/src/extensions/container/set.hpp @@ -189,6 +189,54 @@ public: return ext::iterator_range < decltype ( endIter ) > ( beginIter, endIter ); } + /** + * \brief + * Make range of elements with key equal to the @p key. + * + * \tparam K the key used in the query + * + * \param key the value used in the query + * + * \return selected range of elements + */ + template < class K > + auto equal_range ( K && key ) const & { + auto res = std::set < T, Cmp, Alloc >::equal_range ( std::forward < K > ( key ) ); + return ext::iterator_range < decltype ( res.first ) > ( res.first, res.second ); + } + + /** + * \brief + * Make range of elements with key equal to the @p key. + * + * \tparam K the key used in the query + * + * \param key the value used in the query + * + * \return selected range of elements + */ + template < class K > + auto equal_range ( K && key ) & { + auto res = std::set < T, Cmp, Alloc >::equal_range ( std::forward < K > ( key ) ); + return ext::iterator_range < decltype ( res.first ) > ( res.first, res.second ); + } + + /** + * \brief + * Make range of elements with key equal to the @p key. + * + * \tparam K the key used in the query + * + * \param key the value used in the query + * + * \return selected range of elements + */ + template < class K > + auto equal_range ( K && key ) && { + auto res = std::set < T, Cmp, Alloc >::equal_range ( std::forward < K > ( key ) ); + return ext::make_iterator_range ( make_set_move_iterator < T > ( res.first ), make_set_move_iterator < T > ( res.second ) ); + } + /** * \brief * Test whether the set contains a given key -- GitLab