/// <summary> /// Adds the specified item to the end of the list. /// </summary> /// <param name="item"> The item to add. </param> /// <returns> </returns> public ImmList <T> AddLast(T item) { var ret = new ImmList <T>(Root.AddLast(item, Lineage.Immutable)); ret.Last.AssertEqual(item); ret.Root.Measure.AssertEqual(Root.Measure + 1); return(ret); }
/// <summary> /// Adds the specified list to the end of this one. /// </summary> /// <param name="list"> The list. </param> /// <returns> </returns> ImmList <T> AddLastList(ImmList <T> list) { if (list.IsEmpty) { return(this); } if (IsEmpty) { return(list); } var result = Root.AddLastList(list.Root, Lineage.Immutable); return(result.Wrap()); }
ImmList <T> InsertList(int index, ImmList <T> list) { index.CheckIsBetween("index", -Root.Measure - 1, Root.Measure); list.CheckNotNull("list"); index = index < 0 ? Root.Measure + index + 1 : index; if (index == 0) { return(list.AddLastRange(this)); } if (index == Root.Measure) { return(AddLastRange(list)); } var lineage = Lineage.Mutable(); FingerTree <T> .FTree <Leaf <T> > part1, part2; Root.Split(index, out part1, out part2, Lineage.Immutable); part1 = part1.AddLastList(list.Root, Lineage.Immutable); var result = part1.AddLastList(part2, Lineage.Immutable); return(result.Wrap()); }
/// <summary> /// Joins the specified list to the beginning of this one. /// </summary> /// <param name="list"> The list to join. </param> /// <returns> </returns> ImmList <T> AddFirstList(ImmList <T> list) { return(list.AddLastList(this)); }
/// <summary> /// Inserts a list at the specified index, pushing the element at the index forward. /// </summary> /// <param name="index">The index. Can be negative. </param> /// <param name="list"> The list to insert. </param> /// <returns> </returns> /// <exception cref="ArgumentNullException">Thrown if the argument is null.</exception> /// <exception cref="ArgumentOutOfRangeException">Thrown if the index does not exist in the list.</exception> public ImmList <T> InsertRange(int index, ImmList <T> list) { return(InsertList(index, list)); }
/// <summary> /// Concatenates another list to the beginning of this one. /// </summary> /// <param name="last">The list to add to the beginning.</param> /// <returns></returns> public ImmList <T> AddFirstRange(ImmList <T> last) { last.CheckNotNull("last"); return(AddLastList(last)); }
public ListDebugView(ImmList <T> x) { _x = x; }
public Builder(ImmList <T> inner) { _inner = inner.Root; _lineage = Lineage.Mutable(); }
protected override ISequentialBuilder <T, ImmList <T> > BuilderFrom(ImmList <T> collection) { return(new Builder(collection)); }