mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +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
Notes:
sideshowbarker
2024-07-17 14:29:52 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/1787d94907 Pull-request: https://github.com/SerenityOS/serenity/pull/13490
1 changed files with 2 additions and 0 deletions
|
@ -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