From e5680c712b4e0d27dbd8dedfe3ed03e21bd69589 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 22 Sep 2023 20:24:11 +0200 Subject: [PATCH] util/IntrusiveList: add reverse_iterator --- src/util/IntrusiveList.hxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/util/IntrusiveList.hxx b/src/util/IntrusiveList.hxx index 2604cd6af..bed23cbf0 100644 --- a/src/util/IntrusiveList.hxx +++ b/src/util/IntrusiveList.hxx @@ -412,6 +412,16 @@ public: return {&ToNode(t)}; } + using reverse_iterator = std::reverse_iterator; + + constexpr reverse_iterator rbegin() noexcept { + return reverse_iterator{end()}; + } + + constexpr reverse_iterator rend() noexcept { + return reverse_iterator{begin()}; + } + class const_iterator final { friend IntrusiveList; @@ -487,6 +497,16 @@ public: return {&ToNode(t)}; } + using const_reverse_iterator = std::reverse_iterator; + + constexpr const_reverse_iterator rbegin() const noexcept { + return reverse_iterator{end()}; + } + + constexpr const_reverse_iterator rend() const noexcept { + return reverse_iterator{begin()}; + } + /** * @return an iterator to the item following the specified one */