AK: Add find methods to RedBlackTree returning mutable iterators

Mutable iterators are needed in order for IncrementallyPopulatedStream
to expand chunks after they have been added.
This commit is contained in:
Zaggy1024
2026-01-14 14:38:54 -06:00
committed by Gregory Bertilson
parent 0734a37e24
commit 8405af3f18
Notes: github-actions[bot] 2026-02-06 10:56:28 +00:00

View File

@@ -505,6 +505,22 @@ public:
Iterator end() { return {}; }
Iterator begin_from(K key) { return Iterator(static_cast<Node*>(BaseTree::find(this->m_root, key))); }
Iterator find_largest_not_above_iterator(K key)
{
auto node = static_cast<Node*>(BaseTree::find_largest_not_above(this->m_root, key));
if (!node)
return end();
return Iterator(node, static_cast<Node*>(BaseTree::predecessor(node)));
}
Iterator find_smallest_not_below_iterator(K key)
{
auto node = static_cast<Node*>(BaseTree::find_smallest_not_below(this->m_root, key));
if (!node)
return end();
return Iterator(node, static_cast<Node*>(BaseTree::predecessor(node)));
}
using ConstIterator = RedBlackTreeIterator<RedBlackTree const, V const>;
friend ConstIterator;
ConstIterator begin() const { return ConstIterator(static_cast<Node*>(this->m_minimum)); }