mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
AK: Add reverse iterator as member
This commit is contained in:
parent
f34fff852b
commit
0aed2f0f86
Notes:
sideshowbarker
2024-07-17 17:39:39 +09:00
Author: https://github.com/guerinoni Commit: https://github.com/SerenityOS/serenity/commit/0aed2f0f86 Pull-request: https://github.com/SerenityOS/serenity/pull/12741 Reviewed-by: https://github.com/IdanHo Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/linusg
@ -41,6 +41,11 @@ public:
|
|||||||
ALWAYS_INLINE constexpr Iterator end() { return Iterator::end(*this); }
|
ALWAYS_INLINE constexpr Iterator end() { return Iterator::end(*this); }
|
||||||
ALWAYS_INLINE constexpr ReverseIterator rend() { return ReverseIterator::rend(*this); }
|
ALWAYS_INLINE constexpr ReverseIterator rend() { return ReverseIterator::rend(*this); }
|
||||||
|
|
||||||
|
ALWAYS_INLINE constexpr auto in_reverse()
|
||||||
|
{
|
||||||
|
return ReverseWrapper::in_reverse(*this);
|
||||||
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE PtrType& ptr_at(size_t index) { return Base::at(index); }
|
ALWAYS_INLINE PtrType& ptr_at(size_t index) { return Base::at(index); }
|
||||||
ALWAYS_INLINE const PtrType& ptr_at(size_t index) const { return Base::at(index); }
|
ALWAYS_INLINE const PtrType& ptr_at(size_t index) const { return Base::at(index); }
|
||||||
|
|
||||||
|
@ -704,6 +704,11 @@ public:
|
|||||||
Iterator end() { return Iterator::end(*this); }
|
Iterator end() { return Iterator::end(*this); }
|
||||||
ReverseIterator rend() { return ReverseIterator::rend(*this); }
|
ReverseIterator rend() { return ReverseIterator::rend(*this); }
|
||||||
|
|
||||||
|
ALWAYS_INLINE constexpr auto in_reverse()
|
||||||
|
{
|
||||||
|
return ReverseWrapper::in_reverse(*this);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename TUnaryPredicate>
|
template<typename TUnaryPredicate>
|
||||||
ConstIterator find_if(TUnaryPredicate&& finder) const
|
ConstIterator find_if(TUnaryPredicate&& finder) const
|
||||||
{
|
{
|
||||||
|
@ -567,4 +567,8 @@ TEST_CASE(reverse_range_for_loop)
|
|||||||
int index = 9;
|
int index = 9;
|
||||||
for (auto item : AK::ReverseWrapper::in_reverse(v))
|
for (auto item : AK::ReverseWrapper::in_reverse(v))
|
||||||
EXPECT_EQ(item, index--);
|
EXPECT_EQ(item, index--);
|
||||||
|
|
||||||
|
index = 9;
|
||||||
|
for (auto item : v.in_reverse())
|
||||||
|
EXPECT_EQ(item, index--);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user