コード例 #1
0
ファイル: ImmVector.cs プロジェクト: stjordanis/Imms
        /// <summary>
        ///     Adds the specified element to the end of the vector. O(logn), fast.
        /// </summary>
        /// <param name="item">The item to add.</param>
        /// <returns>ImmVector{`0}.</returns>
        /// <exception cref="InvalidOperationException">Thrown if the data structure exceeds its maximum capacity.</exception>
        public ImmVector <T> AddLast(T item)
        {
#if ASSERTS
            var expected = Length + 1;
#endif
            if (Root.Length >= MaxCapacity)
            {
                throw Errors.Capacity_exceeded();
            }

            ImmVector <T> ret = Root.Add(item, Lineage.Immutable);
#if ASSERTS
            ret.Last.AssertEqual(item);
            ret.Length.AssertEqual(expected);
#endif
            return(ret);
        }
コード例 #2
0
 public bool Add(T item)
 {
     _inner = _inner.Add(item, _lineage);
     return(true);
 }