Class SizeBalancedTreeMethods<TElement>
- Namespace
- Platform.Collections.Methods.Trees
- Assembly
- Platform.Collections.Methods.dll
Represents the size balanced tree methods (Chen Qifeng, "Size Balanced Tree", 2007).
Представляет методы дерева, сбалансированного по размеру (Чэнь Цифэн, «Size Balanced Tree», 2007).
public abstract class SizeBalancedTreeMethods<TElement> : SizedBinaryTreeMethodsBase<TElement> where TElement : IUnsignedNumber<TElement>, IComparisonOperators<TElement, TElement, bool>
Type Parameters
TElement
- Inheritance
-
SizedBinaryTreeMethodsBase<TElement>SizeBalancedTreeMethods<TElement>
- Inherited Members
Remarks
Every node t keeps the size balanced tree properties: each child subtree of t is at least as large as both subtrees of its sibling,
size(t.left) ≥ size(t.right.left), size(t.right.right) and size(t.right) ≥ size(t.left.left), size(t.left.right).
Such a tree with n nodes is at most about 1.44 · log2(n) levels high, the same bound as an AVL tree.
Only subtree sizes are used for balancing.
Every attach and every detach restores the properties with Maintain on each node of the changed path, from the bottom up.
Maintain checks one side of a node with two size comparisons and rotates only when that side became too heavy.
The amortized number of rotations per operation is constant.
Fields
attachCount
Counts attachments for compatibility with derived trees. The counter resets after every second attachment.
protected int attachCount
Field Value
Methods
AfterAttach()
protected override void AfterAttach()
AttachCore(ref TElement, TElement)
Attaches the node to the subtree with the specified root and restores the size balanced tree properties on the way back up.
Присоединяет узел к поддереву с указанным корнем и восстанавливает свойства дерева, сбалансированного по размеру, на обратном пути.
protected override void AttachCore(ref TElement root, TElement node)
Parameters
rootTElementThe reference to the root of the subtree.
Ссылка на корень поддерева.
nodeTElementThe node to attach.
Присоединяемый узел.
BeforeAttach()
protected override void BeforeAttach()
DetachCore(ref TElement, TElement)
Detaches the node from the subtree with the specified root and restores the size balanced tree properties on the way back up.
Отсоединяет узел от поддерева с указанным корнем и восстанавливает свойства дерева, сбалансированного по размеру, на обратном пути.
protected override void DetachCore(ref TElement root, TElement nodeToDetach)
Parameters
rootTElementThe reference to the root of the subtree.
Ссылка на корень поддерева.
nodeToDetachTElementThe node to detach.
Отсоединяемый узел.
Exceptions
- InvalidOperationException
The node is not in the tree, or another node has the same key.
Узла нет в дереве, или другой узел имеет такой же ключ.