AK+Kernel: Remove all the Nonnull*PtrVector classes

This commit is contained in:
Andreas Kling 2023-03-06 18:06:01 +01:00
parent be91020d0b
commit 5aa12da959
Notes: sideshowbarker 2024-07-17 02:28:18 +09:00
5 changed files with 0 additions and 155 deletions

View file

@ -112,12 +112,6 @@ class NonnullRefPtr;
template<typename T>
class NonnullOwnPtr;
template<typename T, size_t inline_capacity = 0>
class NonnullOwnPtrVector;
template<typename T, size_t inline_capacity = 0>
class NonnullRefPtrVector;
template<typename T>
class Optional;
@ -125,9 +119,6 @@ class Optional;
template<typename T>
class NonnullLockRefPtr;
template<typename T, size_t inline_capacity = 0>
class NonnullLockRefPtrVector;
template<typename T>
struct LockRefPtrTraits;
@ -182,9 +173,7 @@ using AK::JsonValue;
using AK::LittleEndianInputBitStream;
using AK::LittleEndianOutputBitStream;
using AK::NonnullOwnPtr;
using AK::NonnullOwnPtrVector;
using AK::NonnullRefPtr;
using AK::NonnullRefPtrVector;
using AK::Optional;
using AK::OwnPtr;
using AK::ReadonlyBytes;
@ -212,7 +201,6 @@ using AK::Vector;
using AK::LockRefPtr;
using AK::LockRefPtrTraits;
using AK::NonnullLockRefPtr;
using AK::NonnullLockRefPtrVector;
# endif
#endif

View file

@ -1,22 +0,0 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/NonnullOwnPtr.h>
#include <AK/NonnullPtrVector.h>
namespace AK {
template<typename T, size_t inline_capacity>
class NonnullOwnPtrVector : public NonnullPtrVector<NonnullOwnPtr<T>, inline_capacity> {
};
}
#if USING_AK_GLOBALLY
using AK::NonnullOwnPtrVector;
#endif

View file

@ -1,77 +0,0 @@
/*
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Vector.h>
namespace AK {
template<typename PtrType, size_t inline_capacity = 0>
class NonnullPtrVector : public Vector<PtrType, inline_capacity> {
using T = typename PtrType::ElementType;
using Base = Vector<PtrType, inline_capacity>;
public:
NonnullPtrVector() = default;
NonnullPtrVector(Vector<PtrType>&& other)
: Base(static_cast<Base&&>(other))
{
}
NonnullPtrVector(Vector<PtrType> const& other)
: Base(static_cast<Base const&>(other))
{
}
NonnullPtrVector(std::initializer_list<PtrType> list)
: Base(list)
{
}
using Base::size;
using ConstIterator = SimpleIterator<NonnullPtrVector const, T>;
using Iterator = SimpleIterator<NonnullPtrVector, T>;
using ReverseIterator = SimpleReverseIterator<NonnullPtrVector, T>;
using ReverseConstIterator = SimpleReverseIterator<NonnullPtrVector const, T>;
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() const { return ReverseWrapper::in_reverse(*this); }
Optional<size_t> find_first_index(T const& value) const
{
if (auto const index = AK::find_index(begin(), end(), value);
index < size()) {
return index;
}
return {};
}
ALWAYS_INLINE PtrType& ptr_at(size_t index) const { return const_cast<PtrType&>(Base::at(index)); }
ALWAYS_INLINE T& at(size_t index) const { return const_cast<T&>(*Base::at(index)); }
ALWAYS_INLINE T& operator[](size_t index) const { return at(index); }
ALWAYS_INLINE T& first() const { return at(0); }
ALWAYS_INLINE T& last() const { return at(size() - 1); }
private:
// NOTE: You can't use resize() on a NonnullFooPtrVector since making the vector
// bigger would require being able to default-construct NonnullFooPtrs.
// Instead, use shrink(new_size).
void resize(size_t) = delete;
};
}

View file

@ -1,23 +0,0 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/NonnullPtrVector.h>
#include <AK/NonnullRefPtr.h>
namespace AK {
template<typename T, size_t inline_capacity>
class NonnullRefPtrVector : public NonnullPtrVector<NonnullRefPtr<T>, inline_capacity> {
using NonnullPtrVector<NonnullRefPtr<T>, inline_capacity>::NonnullPtrVector;
};
}
#if USING_AK_GLOBALLY
using AK::NonnullRefPtrVector;
#endif

View file

@ -1,21 +0,0 @@
/*
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/NonnullPtrVector.h>
#include <Kernel/Library/NonnullLockRefPtr.h>
namespace AK {
template<typename T, size_t inline_capacity>
class NonnullLockRefPtrVector : public NonnullPtrVector<NonnullLockRefPtr<T>, inline_capacity> {
using NonnullPtrVector<NonnullLockRefPtr<T>, inline_capacity>::NonnullPtrVector;
};
}
using AK::NonnullLockRefPtrVector;