AK: Add const variant of Vector::in_reverse()

This commit is contained in:
Andreas Kling 2022-03-17 12:30:04 +01:00
parent f47c92bd2e
commit fc6b7fcd97
Notes: sideshowbarker 2024-07-17 20:22:04 +09:00
2 changed files with 13 additions and 4 deletions

View file

@ -32,19 +32,20 @@ public:
using ConstIterator = SimpleIterator<const NonnullPtrVector, const T>;
using Iterator = SimpleIterator<NonnullPtrVector, T>;
using ReverseIterator = SimpleReverseIterator<NonnullPtrVector, T>;
using ReverseConstIterator = SimpleReverseIterator<NonnullPtrVector, T const>;
ALWAYS_INLINE constexpr ConstIterator begin() const { return ConstIterator::begin(*this); }
ALWAYS_INLINE constexpr Iterator begin() { return Iterator::begin(*this); }
ALWAYS_INLINE constexpr ReverseIterator rbegin() { return ReverseIterator::rbegin(*this); }
ALWAYS_INLINE constexpr ReverseConstIterator rbegin() const { return ReverseConstIterator::rbegin(*this); }
ALWAYS_INLINE constexpr ConstIterator end() const { return ConstIterator::end(*this); }
ALWAYS_INLINE constexpr Iterator end() { return Iterator::end(*this); }
ALWAYS_INLINE constexpr ReverseIterator rend() { return ReverseIterator::rend(*this); }
ALWAYS_INLINE constexpr ReverseConstIterator rend() const { return ReverseConstIterator::rend(*this); }
ALWAYS_INLINE constexpr auto in_reverse()
{
return ReverseWrapper::in_reverse(*this);
}
ALWAYS_INLINE constexpr auto in_reverse() { return ReverseWrapper::in_reverse(*this); }
ALWAYS_INLINE constexpr auto in_reverse() const { return ReverseWrapper::in_reverse(*this); }
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); }

View file

@ -702,20 +702,28 @@ public:
using ConstIterator = SimpleIterator<Vector const, VisibleType const>;
using Iterator = SimpleIterator<Vector, VisibleType>;
using ReverseIterator = SimpleReverseIterator<Vector, VisibleType>;
using ReverseConstIterator = SimpleReverseIterator<Vector const, VisibleType const>;
ConstIterator begin() const { return ConstIterator::begin(*this); }
Iterator begin() { return Iterator::begin(*this); }
ReverseIterator rbegin() { return ReverseIterator::rbegin(*this); }
ReverseConstIterator rbegin() const { return ReverseConstIterator::rbegin(*this); }
ConstIterator end() const { return ConstIterator::end(*this); }
Iterator end() { return Iterator::end(*this); }
ReverseIterator rend() { return ReverseIterator::rend(*this); }
ReverseConstIterator rend() const { return ReverseConstIterator::rend(*this); }
ALWAYS_INLINE constexpr auto in_reverse()
{
return ReverseWrapper::in_reverse(*this);
}
ALWAYS_INLINE constexpr auto in_reverse() const
{
return ReverseWrapper::in_reverse(*this);
}
template<typename TUnaryPredicate>
ConstIterator find_if(TUnaryPredicate&& finder) const
{