AK: Add key getter to IntrusiveRedBlackTreeNode

This commit is contained in:
Idan Horowitz 2021-09-08 03:20:30 +03:00
parent cb9720baab
commit 0279fb4dd3
Notes: sideshowbarker 2024-07-18 04:25:55 +09:00

View File

@ -52,7 +52,7 @@ public:
{
auto& node = value.*member;
VERIFY(!node.m_in_tree);
node.key = key;
static_cast<typename BaseTree::Node&>(node).key = key;
BaseTree::insert(&node);
if constexpr (!TreeNode::IsRaw)
node.m_self.reference = &value; // Note: Self-reference ensures that the object will keep a ref to itself when the Container is a smart pointer.
@ -176,6 +176,11 @@ public:
return m_in_tree;
}
[[nodiscard]] K key() const
{
return BaseRedBlackTree<K>::Node::key;
}
static constexpr bool IsRaw = IsPointer<Container>;
#ifndef __clang__