/// <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> /// Returns a range of elements. Doesn't support negative indexing. /// </summary> /// <param name="from"></param> /// <param name="count"></param> /// <returns></returns> protected override ImmList <T> GetRange(int @from, int count) { @from.CheckIsBetween("start", 0, Root.Measure - 1); (@from + count).CheckIsBetween("count", 0, Root.Measure); if (count == 0) { return(empty); } if (count == 1) { var res = Root[@from]; return(EmptyFTree.AddLast(res, Lineage.Immutable).Wrap()); } FingerTree <T> .FTree <Leaf <T> > first, last; Root.Split(@from, out first, out last, Lineage.Immutable); last.Split(count, out first, out last, Lineage.Immutable); return(first.Wrap()); }
public bool Add(T item) { _inner = _inner.AddLast(item, _lineage); return(true); }