AK: Add RedBlackTree::find_largest_not_above_iterator

It's a version of find_largest_not_above that returns an iterator.
This commit is contained in:
Itamar 2021-06-19 11:23:02 +03:00 committed by Andreas Kling
parent 98a774a68d
commit d26f4f9e8c
Notes: sideshowbarker 2024-07-18 12:01:36 +09:00

View file

@ -464,6 +464,12 @@ public:
ConstIterator end() const { return {}; }
ConstIterator begin_from(K key) const { return ConstIterator(static_cast<Node*>(BaseTree::find(this->m_root, key))); }
ConstIterator find_largest_not_above_iterator(K key) const
{
auto node = static_cast<Node*>(BaseTree::find_largest_not_above(this->m_root, key));
return ConstIterator(node, static_cast<Node*>(BaseTree::predecessor(node)));
}
V unsafe_remove(K key)
{
auto* node = BaseTree::find(this->m_root, key);