mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-02 22:24:26 +00:00
AK: Add begin_from(V&) APIs to IntrusiveRedBlackTree
This method exploits the fact that the values themselves hold the tree pointers, and as a result this let's us skip the O(logn) traversal down to the matching Node for a Key-Value pair.
This commit is contained in:
parent
30e6b313b4
commit
1787d94907
|
@ -117,11 +117,13 @@ public:
|
|||
Iterator begin() { return Iterator(static_cast<TreeNode*>(this->m_minimum)); }
|
||||
Iterator end() { return {}; }
|
||||
Iterator begin_from(K key) { return Iterator(static_cast<TreeNode*>(BaseTree::find(this->m_root, key))); }
|
||||
Iterator begin_from(V& value) { return Iterator(&(value.*member)); }
|
||||
|
||||
using ConstIterator = BaseIterator<const V>;
|
||||
ConstIterator begin() const { return ConstIterator(static_cast<TreeNode*>(this->m_minimum)); }
|
||||
ConstIterator end() const { return {}; }
|
||||
ConstIterator begin_from(K key) const { return ConstIterator(static_cast<TreeNode*>(BaseTree::find(this->m_rootF, key))); }
|
||||
ConstIterator begin_from(V const& value) const { return Iterator(&(value.*member)); }
|
||||
|
||||
bool remove(K key)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue