Class RecursionlessSizeBalancedTreeMethods<TElement>

Namespace
Platform.Collections.Methods.Trees
Assembly
Platform.Collections.Methods.dll

Represents the size balanced tree methods that do not use recursion.

Представляет методы дерева, сбалансированного по размеру, не использующие рекурсию.

public abstract class RecursionlessSizeBalancedTreeMethods<TElement> : SizedBinaryTreeMethodsBase<TElement> where TElement : IUnsignedNumber<TElement>, IComparisonOperators<TElement, TElement, bool>

Type Parameters

TElement
Inheritance
RecursionlessSizeBalancedTreeMethods<TElement>
Inherited Members

Remarks

The algorithm is the same as in SizeBalancedTreeMethods<TElement> and builds the same trees. The path from the root and the pending Maintain steps are kept in explicit stacks instead of the call stack. An attach also remembers the direction it took at every node of the path, so on the way back up it compares only the size of the grandchild that grew, until a rotation changes the children (see MaintainAttachPath).

A position in the tree is stored as its parent and the side of the parent, because a rotation replaces the node at a position but not the position itself. The root position has no parent.

A tree built by other code, for example by older versions of this class, is rebuilt once when an operation finds a path longer than GetMaximumBalancedHeight(TElement) allows.

The stacks belong to the instance, so one instance must not be used by several threads at once.

Methods

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

root TElement

The reference to the root of the subtree.

Ссылка на корень поддерева.

node TElement

The node to attach.

Присоединяемый узел.

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 node)

Parameters

root TElement

The reference to the root of the subtree.

Ссылка на корень поддерева.

node TElement

The node to detach.

Отсоединяемый узел.

Exceptions

InvalidOperationException

The node is not in the tree, or another node has the same key.

Узла нет в дереве, или другой узел имеет такой же ключ.

See Also