提交 2f175074 编写于 作者: S Sasha Levin 提交者: Linus Torvalds

Documentation: Update augmented rbtree documentation

Current documentation referred to the old method of handling augmented
trees.  Update documentation to correspond with the changes done in
commit b945d6b2 ("rbtree: Undo augmented trees performance damage
and regression").

Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: David Woodhouse <David.Woodhouse@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Acked-by: NIngo Molnar <mingo@elte.hu>
Acked-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: NSasha Levin <levinsasha928@gmail.com>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 81d67439
...@@ -196,15 +196,20 @@ Support for Augmented rbtrees ...@@ -196,15 +196,20 @@ Support for Augmented rbtrees
Augmented rbtree is an rbtree with "some" additional data stored in each node. Augmented rbtree is an rbtree with "some" additional data stored in each node.
This data can be used to augment some new functionality to rbtree. This data can be used to augment some new functionality to rbtree.
Augmented rbtree is an optional feature built on top of basic rbtree Augmented rbtree is an optional feature built on top of basic rbtree
infrastructure. rbtree user who wants this feature will have an augment infrastructure. An rbtree user who wants this feature will have to call the
callback function in rb_root initialized. augmentation functions with the user provided augmentation callback
when inserting and erasing nodes.
This callback function will be called from rbtree core routines whenever
a node has a change in one or both of its children. It is the responsibility On insertion, the user must call rb_augment_insert() once the new node is in
of the callback function to recalculate the additional data that is in the place. This will cause the augmentation function callback to be called for
rb node using new children information. Note that if this new additional each node between the new node and the root which has been affected by the
data affects the parent node's additional data, then callback function has insertion.
to handle it and do the recursive updates.
When erasing a node, the user must call rb_augment_erase_begin() first to
retrieve the deepest node on the rebalance path. Then, after erasing the
original node, the user must call rb_augment_erase_end() with the deepest
node found earlier. This will cause the augmentation function to be called
for each affected node between the deepest node and the root.
Interval tree is an example of augmented rb tree. Reference - Interval tree is an example of augmented rb tree. Reference -
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册