Пример #1
0
        public slice <T> AppendAll(slice <T> items)
        {
            // TODO: naive implementation (based on AppendByte sample in
            // https://blog.golang.org/go-slices-usage-and-internals), optimize
            var len = this.Length;
            var n   = Length + items.Length;
            var s   = this;

            if (n > this.Capacity) // if necessary, reallocate
            {
                // allocate double what's needed, for future growth (+1 in case n == 0)
                s = slice <T> .Make((n + 1) * 2);

                this.CopyTo(s);
            }
            s = s.Slice(0, n);
            items.CopyTo(s.Slice(len, n));
            return(s);
        }
Пример #2
0
 public int CopyFrom(slice <T> src)
 {
     return(src.CopyTo(this));
 }