private RootwardNode() { this.Parent = this; this.SiblingOfChild = LeafwardNode.Nil; this.Data = null; this.IsRed = false; }
public LeafwardNode(KeyVal data, bool isRed, LeafwardNode left, LeafwardNode right, Func <TAggregate, TKey, TVal, TAggregate, TAggregate> aggregator) { this.Data = data; this.Left = left; this.Right = right; this.IsRed = isRed; this.Aggregate = data == null ? default(TAggregate) : aggregator(left.Aggregate, data.Key, data.Val, right.Aggregate); this.Count = data == null ? 0 : left.Count + 1 + right.Count; }
public ZipperNode(KeyVal content, bool isRed, LeafwardNode left, LeafwardNode right, RootwardNode parent, Func <TAggregate, TKey, TVal, TAggregate, TAggregate> aggregator) { this.Data = content; this.IsRed = isRed; this.Left = left; this.Right = right; this.Parent = parent; this.Aggregator = aggregator; }
public ZipperNode(Func <TAggregate, TKey, TVal, TAggregate, TAggregate> aggregator) { this.Left = LeafwardNode.Nil; this.Right = LeafwardNode.Nil; this.Parent = RootwardNode.Nil; this.Data = null; this.IsRed = false; this.Aggregator = aggregator; }
public PersistentAggregatingRedBlackTree(Func <TAggregate, TKey, TVal, TAggregate, TAggregate> aggregator, IComparer <TKey> comparer = null) { if (aggregator == null) { throw new ArgumentNullException("aggregator"); } this._root = LeafwardNode.Nil; this._aggregator = aggregator; this._comparer = comparer ?? Comparer <TKey> .Default; }
public RootwardNode(KeyVal data, bool isRed, RootwardNode parent, LeafwardNode siblingOfChild, bool isLeft) { if (data == null) { throw new ArgumentNullException("data"); } if (parent == null) { throw new ArgumentNullException("parent"); } if (siblingOfChild == null) { throw new ArgumentNullException("siblingOfChild"); } this.Data = data; this.Parent = parent; this.SiblingOfChild = siblingOfChild; this.IsChildOnLeft = isLeft; this.IsRed = isRed; }
/// <summary> /// Rotates the tree, maintaining sorted order, such that the node p becomes the child of its child in the specified direction. /// The node p's direction from its new parent (former child) will be the opposite of the specified direction. /// The return value is the former child. /// </summary> public ZipperNode Rotate(bool toLeft) { // before // -> v1 //p=v2 // -> v3 // -> v4 // -> v5 var p = this; var n1 = p.Child(toLeft); var n2 = p; var n3 = p.Child(!toLeft).Child(toLeft); var n4 = p.Child(!toLeft); var n5 = p.Child(!toLeft).Child(!toLeft); // after // -> v1 // -> v2 // -> v3 //r=v4 // -> v5 return(From(p.Parent, n4.Data, n4.IsRed, LeafwardNode.From(n2.Data, n2.IsRed, n1, n3, toLeft, Aggregator), n5, toLeft, Aggregator)); }
public static LeafwardNode From(KeyVal data, bool isRed, LeafwardNode c1, LeafwardNode c2, bool c1IsLeft, Func <TAggregate, TKey, TVal, TAggregate, TAggregate> aggregator) { return(new LeafwardNode(data, isRed, c1IsLeft ? c1 : c2, c1IsLeft ? c2 : c1, aggregator)); }
private PersistentAggregatingRedBlackTree(LeafwardNode root, Func <TAggregate, TKey, TVal, TAggregate, TAggregate> aggregator, IComparer <TKey> comparer) { this._root = root; this._aggregator = aggregator; this._comparer = comparer; }
private LeafwardNode() { this.Left = this.Right = this; }
public static ZipperNode From(RootwardNode parent, KeyVal content, bool isRed, LeafwardNode c1, LeafwardNode c2, bool c1IsLeft, Func <TAggregate, TKey, TVal, TAggregate, TAggregate> aggregator) { return(new ZipperNode(content, isRed, c1IsLeft ? c1 : c2, c1IsLeft ? c2 : c1, parent, aggregator)); }