void SetCurrent(object v) { _current = (Leaf <TValue>)v; }
public override FTree <TChild> Update(int index, Leaf <TValue> leaf, Lineage lineage) { return(new Single(CenterDigit.Update(index, leaf, lineage), lineage)); }
public Enumerator(Leaf node, bool forward, int startIndex = 0) { _node = node; _forward = forward; _index = startIndex - 1; }
public abstract FTree<TChild> Insert(int index, Leaf<TValue> leaf, Lineage lineage);
public abstract FTree<TChild> Update(int index, Leaf<TValue> leaf, Lineage lineage);
public override void Fuse(Leaf <TValue> after, out Leaf <TValue> firstRes, out Leaf <TValue> lastRes, Lineage lineage) { throw ImplErrors.Invalid_invocation("FingerTree Leaf"); }
public override void Insert(int index, Leaf <TValue> leaf, out Leaf <TValue> leftmost, out Leaf <TValue> rightmost, Lineage lineage) { leftmost = leaf; rightmost = this; }
public bool Equals(Leaf <TValue> other) { return(Value.Equals(other.Value)); }
public override Leaf <TValue> Update(int index, Leaf <TValue> leaf, Lineage lineage) { return(leaf); }
public abstract TObject Update(int index, Leaf <TValue> leaf, Lineage lineage);
/// <summary> /// Inserts the leaf at the specified index, returning the primary result in 'value' and a rightmost overflow result in /// 'rightmost' /// </summary> /// <param name="index">The index.</param> /// <param name="leaf">The leaf.</param> /// <param name="value">The primary result digit. Cannot be null.</param> /// <param name="rightmost1">The rightmost overflow result, when the digit cannot contain the new leaf. May be null.</param> /// <param name="lineage">The lineage.</param> public abstract void Insert(int index, Leaf <TValue> leaf, out TObject value, out TObject rightmost1, Lineage lineage);
public override void Insert(int index, Leaf <TValue> leaf, out Digit leftmost, out Digit rightmost, Lineage lineage) { #if ASSERTS leaf.AssertNotNull(); #endif var whereIsThisIndex = WhereIsThisIndex(index); TChild myLeftmost; TChild myRightmost; leftmost = null; rightmost = null; switch (whereIsThisIndex) { case IN_START: case IN_MIDDLE_OF_1: First.Insert(index, leaf, out myLeftmost, out myRightmost, lineage); if (Size == 4 && myRightmost != null) { leftmost = new Digit(myLeftmost, myRightmost, Second, lineage); rightmost = MutateOrCreate(Third, Fourth, lineage); return; } leftmost = myRightmost != null ? CreateCheckNull(lineage, myLeftmost, myRightmost, Second, Third) : CreateCheckNull(lineage, myLeftmost, Second, Third, Fourth); rightmost = null; return; case IN_START_OF_2: case IN_MIDDLE_OF_2: Second.Insert(index - First.Measure, leaf, out myLeftmost, out myRightmost, lineage); if (Size == 4 && myRightmost != null) { leftmost = new Digit(First, myLeftmost, myRightmost, lineage); rightmost = MutateOrCreate(Third, Fourth, lineage); return; } leftmost = myRightmost != null ? CreateCheckNull(lineage, First, myLeftmost, myRightmost, Third) : CreateCheckNull(lineage, First, myLeftmost, Third, Fourth); rightmost = null; return; case IN_START_OF_3: case IN_MIDDLE_OF_3: Third.Insert(index - First.Measure - Second.Measure, leaf, out myLeftmost, out myRightmost, lineage); if (Size == 4 && myRightmost != null) { leftmost = new Digit(First, Second, myLeftmost, lineage); rightmost = MutateOrCreate(myRightmost, Fourth, lineage); return; } leftmost = myRightmost != null ? CreateCheckNull(lineage, First, Second, myLeftmost, myRightmost) : CreateCheckNull(lineage, First, Second, myLeftmost, Fourth); rightmost = null; return; case IN_START_OF_4: case IN_MIDDLE_OF_4: Fourth.Insert(index - Measure + Fourth.Measure, leaf, out myLeftmost, out myRightmost, lineage); if (Size == 4 && myRightmost != null) { leftmost = new Digit(First, Second, Third, lineage); rightmost = MutateOrCreate(myLeftmost, myRightmost, lineage); return; } leftmost = MutateOrCreate(First, Second, Third, myLeftmost, lineage); rightmost = null; return; default: throw ImplErrors.Invalid_execution_path(""); } }