示例#1
0
 public LstInternal <A> Insert(int index, A value)
 {
     if (index < 0 || index > Root.Count)
     {
         throw new IndexOutOfRangeException();
     }
     return(Wrap(ListModule.Insert(Root, value, Rev ? Count - index - 1 : index), Rev));
 }
示例#2
0
 /// <summary>
 /// Insert value at specified index
 /// </summary>
 public Lst <T> Insert(int index, T value)
 {
     if (index < 0 || index > Root.Count)
     {
         throw new IndexOutOfRangeException();
     }
     return(new Lst <T>(ListModule.Insert(Root, value, Rev ? Count - index - 1 : index), Rev));
 }
示例#3
0
        public LstInternal <A> AddRange(IEnumerable <A> items)
        {
            if (items == null)
            {
                return(this);
            }
            var lst  = new List <A>(Rev ? items.Reverse() : items);
            var tree = ListModule.FromList(lst, 0, lst.Count);

            return(Wrap(ListModule.Insert(Root, tree, Rev ? 0 : Root.Count), Rev));
        }
示例#4
0
        /// <summary>
        /// Insert range of values at specified index
        /// </summary>
        public Lst <T> InsertRange(int index, IEnumerable <T> items)
        {
            if (items == null)
            {
                return(this);
            }
            if (index < 0 || index > Root.Count)
            {
                throw new IndexOutOfRangeException();
            }

            var lst  = new List <T>(Rev ? items.Reverse() : items);
            var tree = ListModule.FromList(lst, 0, lst.Count);

            return(new Lst <T>(ListModule.Insert(Root, tree, Rev ? Count - index - 1 : index), Rev));
        }
示例#5
0
        public LstInternal <A> InsertRange(int index, IEnumerable <A> items, Pred <A> pred)
        {
            if (items == null)
            {
                return(this);
            }
            if (index < 0 || index > Root.Count)
            {
                throw new IndexOutOfRangeException();
            }

            var lst = new List <A>(Rev ? items.Reverse() : items);

            foreach (var item in items)
            {
                if (!pred.True(item))
                {
                    throw new ArgumentOutOfRangeException(nameof(items));
                }
            }
            var tree = ListModule.FromList(lst, 0, lst.Count);

            return(Wrap(ListModule.Insert(Root, tree, Rev ? Count - index - 1 : index), Rev));
        }
示例#6
0
 public LstInternal <A> Add(A value) =>
 Wrap(ListModule.Insert(Root, value, Rev ? 0 : Root.Count), Rev);
示例#7
0
 /// <summary>
 /// Add an item to the end of the list
 /// </summary>
 public Lst <T> Add(T value) =>
 new Lst <T>(ListModule.Insert(Root, value, Rev ? 0 : Root.Count), Rev);