1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:27:35 +00:00

AK: Make IntrusiveRedBlackTree capable of holding non-raw pointers

This is completely based on e4412f1f59
and will allow us to convert some AK::HashMap users in the kernel.
This commit is contained in:
Idan Horowitz 2021-09-08 01:57:49 +03:00
parent 7bb3b2839e
commit 1db9250766
4 changed files with 159 additions and 35 deletions

View file

@ -9,6 +9,7 @@
#include <AK/Assertions.h>
#include <AK/BitCast.h>
#include <AK/Forward.h>
#include <AK/IntrusiveDetails.h>
#include <AK/Noncopyable.h>
#include <AK/StdLibExtras.h>
@ -17,20 +18,10 @@ namespace AK {
namespace Detail {
template<typename T, typename Container = RawPtr<T>>
class IntrusiveListNode;
template<typename T, typename Container>
struct SubstituteIntrusiveListNodeContainerType {
using Type = Container;
};
template<typename T>
struct SubstituteIntrusiveListNodeContainerType<T, NonnullRefPtr<T>> {
using Type = RefPtr<T>;
};
}
template<typename T, typename Container = RawPtr<T>>
using IntrusiveListNode = Detail::IntrusiveListNode<T, typename Detail::SubstituteIntrusiveListNodeContainerType<T, Container>::Type>;
using IntrusiveListNode = Detail::IntrusiveListNode<T, typename Detail::SubstituteIntrusiveContainerType<T, Container>::Type>;
template<typename T, typename Container>
class IntrusiveListStorage {
@ -157,14 +148,6 @@ private:
IntrusiveListStorage<T, Container> m_storage;
};
template<typename Contained, bool _IsRaw>
struct SelfReferenceIfNeeded {
Contained reference = nullptr;
};
template<typename Contained>
struct SelfReferenceIfNeeded<Contained, true> {
};
namespace Detail {
template<typename T, typename Container>