예제 #1
0
        public WrappedArray <T> Concat(params WrappedArray <T>[] range)
        {
            if (range.IsNull())
            {
                throw new System.NullReferenceException();
            }
            var newSize = array.Length;

            for (var i = 0; i < range.Length; i++)
            {
                newSize += range[i].Or(new WrappedArray <T>()).array.Length;
            }
            var result = new WrappedArray <T>(newSize);

            for (var i = 0; i < array.Length; i++)
            {
                result.array[i] = array[i];
            }
            var offset = array.Length;

            for (var i = 0; i < range.Length; i++)
            {
                for (var j = 0; j < range[i].Or(new WrappedArray <T>()).array.Length; j++)
                {
                    result.array[offset + j] = range[i].array[j];
                }
                offset += range[i].Or(new WrappedArray <T>()).array.Length;
            }
            return(result);
        }
예제 #2
0
        public WrappedArray <T> Copy()
        {
            var result = new WrappedArray <T>(array.Length);

            for (var i = 0; i < array.Length; i++)
            {
                result.array[i] = array[i];
            }
            return(result);
        }
예제 #3
0
        public WrappedArray <T> Slice(int fromIndex, int count)
        {
            if ((fromIndex < 0) || (fromIndex >= array.Length))
            {
                throw new System.ArgumentOutOfRangeException("fromIndex");
            }
            if ((count <= 0) || (count > array.Length))
            {
                throw new System.ArgumentOutOfRangeException("count");
            }
            if (fromIndex >= count)
            {
                throw new System.ArgumentException("fromIndex >= count");
            }
            var result = new WrappedArray <T>(count - fromIndex);

            for (var i = fromIndex; i < count; i++)
            {
                result.array[i - fromIndex] = array[i];
            }
            return(result);
        }