diff --git a/alib2std/src/extensions/container/set.hpp b/alib2std/src/extensions/container/set.hpp index b94a10c7330ddf7feab44028d2de5c6bace0866a..469ead9170d1d6b64ee4129e68ad60f0de2739db 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