Beispiel #1
0
 /// <summary>
 /// Construct array index
 /// </summary>
 /// <param name="arrayInfo">Array information class.</param>
 /// <param name="bound">If truthen.</param>
 public ArrayLongIndex(ArrayLongInfo arrayInfo, bool bound)
 {
     _arrayInfo  = arrayInfo;
     _dimIndices = new long[_arrayInfo.Rank];
     _flatIndex  = bound && _arrayInfo.Length != 0 ? _arrayInfo.Length - 1 : 0;
     if (!bound)
     {
         _arrayInfo.GetMinDimIndices(_dimIndices);
     }
     else
     {
         _arrayInfo.GetMaxDimIndices(_dimIndices);
     }
 }
Beispiel #2
0
        public ArrayLongFlatSlice(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 LongRange(0L, array.LongLength);
            _arrayInfo = new RegularArrayLongInfo(array.GetRegularArrayLongDimensions());
        }
Beispiel #3
0
        public ArrayLongDimSlice(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 LongRange[_array.Rank];
            for (int i = 0; i < array.Rank; i++)
            {
                _ranges[i] = new LongRange(0L, array.GetLongLength(i));
            }
            _arrayInfo = new RegularArrayLongInfo(array.GetRegularArrayLongDimensions());
        }
Beispiel #4
0
        public ArrayLongDimSlice(Array array, LongRange[] 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    = (LongRange[])ranges.Clone();
            _arrayInfo = new RegularArrayLongInfo(array.GetRegularArrayLongDimensions());
        }
Beispiel #5
0
        public ArrayLongFlatSlice(Array array, LongRange 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.LongLength)
            {
                throw new ArgumentOutOfRangeException("range.Index");
            }
            if (range.Count < 0 || range.Count > array.LongLength - range.Index)
            {
                throw new ArgumentOutOfRangeException("range.Count");
            }

            _array     = array;
            _range     = range;
            _arrayInfo = new RegularArrayLongInfo(array.GetRegularArrayLongDimensions());
        }
Beispiel #6
0
 /// <summary>
 /// Construct array index
 /// </summary>
 /// <param name="arrayInfo">Array information class.</param>
 public ArrayLongIndex(ArrayLongInfo arrayInfo)
     : this(arrayInfo, false)
 {
 }