예제 #1
0
 /// <summary>
 /// Construct array index
 /// </summary>
 /// <param name="arrayInfo">Array information class.</param>
 /// <param name="bound">If truthen.</param>
 public ArrayIndex(ArrayInfo arrayInfo, bool bound)
 {
     _arrayInfo  = arrayInfo;
     _dimIndices = new int[_arrayInfo.Rank];
     _flatIndex  = bound && _arrayInfo.Length != 0 ? _arrayInfo.Length - 1 : 0;
     if (!bound)
     {
         _arrayInfo.GetMinDimIndices(_dimIndices);
     }
     else
     {
         _arrayInfo.GetMaxDimIndices(_dimIndices);
     }
 }
예제 #2
0
        public ArrayFlatSlice(Array array)
        {
            if (array == null)
            {
                throw new ArgumentNullException("array");
            }
            if (!typeof(T).Equals(array.GetType().GetElementType()))
            {
                throw new ArgumentException(ArrayResources.Default.Strings[ArrayMessage.InvalidArrayElementType]);
            }

            _array     = array;
            _range     = new Range(0, array.Length);
            _arrayInfo = new RegularArrayInfo(array.GetRegularArrayDimensions());
        }
예제 #3
0
        public ArrayDimSlice(Array array)
        {
            if (array == null)
            {
                throw new ArgumentNullException("array");
            }
            if (!typeof(T).Equals(array.GetType().GetElementType()))
            {
                throw new ArgumentException(ArrayResources.Default.Strings[ArrayMessage.InvalidArrayElementType], "array");
            }

            _array  = array;
            _ranges = new Range[_array.Rank];
            for (int i = 0; i < array.Rank; i++)
            {
                _ranges[i] = new Range(0, array.GetLength(i));
            }
            _arrayInfo = new RegularArrayInfo(array.GetRegularArrayDimensions());
        }
예제 #4
0
        public ArrayDimSlice(Array array, Range[] ranges)
        {
            if (array == null)
            {
                throw new ArgumentNullException("array");
            }
            if (!typeof(T).Equals(array.GetType().GetElementType()))
            {
                throw new ArgumentException(ArrayResources.Default.Strings[ArrayMessage.InvalidArrayElementType], "array");
            }
            if (ranges == null)
            {
                throw new ArgumentNullException("ranges");
            }
            if (ranges.Length != array.Rank)
            {
                throw new ArgumentException(ArrayResources.Default.Strings[ArrayMessage.InvalidArrayLength], "ranges");
            }
            for (int i = 0; i < ranges.Length; i++)
            {
                try
                {
                    if (ranges[i].Index <0 || ranges[i].Index> array.GetLength(i))
                    {
                        throw new ArgumentOutOfRangeException("range.Index");
                    }
                    if (ranges[i].Count <0 || ranges[i].Count> array.GetLength(i) - ranges[i].Index)
                    {
                        throw new ArgumentOutOfRangeException("range.Count");
                    }
                }
                catch (Exception ex)
                {
                    throw new ArgumentRegularArrayElementException("ranges", ex, i);
                }
            }

            _array     = array;
            _ranges    = (Range[])ranges.Clone();
            _arrayInfo = new RegularArrayInfo(array.GetRegularArrayDimensions());
        }
예제 #5
0
        public ArrayFlatSlice(Array array, Range range)
        {
            if (array == null)
            {
                throw new ArgumentNullException("array");
            }
            if (!typeof(T).Equals(array.GetType().GetElementType()))
            {
                throw new ArgumentException(ArrayResources.Default.Strings[ArrayMessage.InvalidArrayElementType]);
            }
            if (range.Index < 0 || range.Index > array.Length)
            {
                throw new ArgumentOutOfRangeException("range.Index");
            }
            if (range.Count < 0 || range.Count > array.Length - range.Index)
            {
                throw new ArgumentOutOfRangeException("range.Count");
            }

            _array     = array;
            _range     = range;
            _arrayInfo = new RegularArrayInfo(array.GetRegularArrayDimensions());
        }
예제 #6
0
 /// <summary>
 /// Construct array index
 /// </summary>
 /// <param name="arrayInfo">Array information class.</param>
 public ArrayIndex(ArrayInfo arrayInfo)
     : this(arrayInfo, false)
 {
 }