mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:57:45 +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
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 begin() { return Iterator(static_cast<TreeNode*>(this->m_minimum)); }
|
||||||
Iterator end() { return {}; }
|
Iterator end() { return {}; }
|
||||||
Iterator begin_from(K key) { return Iterator(static_cast<TreeNode*>(BaseTree::find(this->m_root, key))); }
|
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>;
|
using ConstIterator = BaseIterator<const V>;
|
||||||
ConstIterator begin() const { return ConstIterator(static_cast<TreeNode*>(this->m_minimum)); }
|
ConstIterator begin() const { return ConstIterator(static_cast<TreeNode*>(this->m_minimum)); }
|
||||||
ConstIterator end() const { return {}; }
|
ConstIterator end() const { return {}; }
|
||||||
ConstIterator begin_from(K key) const { return ConstIterator(static_cast<TreeNode*>(BaseTree::find(this->m_rootF, key))); }
|
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)
|
bool remove(K key)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue