예제 #1
0
파일: XArrayHelper.cs 프로젝트: xxdoc/SKS
 ///<summary>
 ///Creates a cleared a XArrayHelper.
 ///</summary>
 ///<param name="arr">XArrayHelper whose elements need to be cleared.</param>
 public void Clear(ref XArrayHelper arr)
 {
     int[] length = new int[] { 1, 0 };
     int[] lowerB = new int[] { arr.DimensionLowerBounds[0], arr.DimensionLowerBounds[1] };
     this.Clear();
     arr.RedimXArray(length, lowerB);
 }
예제 #2
0
파일: XArrayHelper.cs 프로젝트: xxdoc/SKS
 ///<summary>
 ///Creates a XArrayHelper and copies the values from a XArrayHelper.
 ///</summary>
 ///<param name="table">The source XArrayHelper to be copied.</param>
 public void LoadRows(XArrayHelper table)
 {
     this.RedimXArray(new int[] { table.GetUpperBound(0), table.GetUpperBound(1) }, new int[] { table.GetLowerBound(0), table.GetLowerBound(1) });
     for (int row = table.GetLowerBound(0); row <= table.GetUpperBound(0); row++)
     {
         for (int col = table.GetLowerBound(1); col <= table.GetUpperBound(1); col++)
         {
             this.SetValue(table.GetValue(row, col), row, col);
         }
     }
 }
예제 #3
0
파일: XArrayHelper.cs 프로젝트: xxdoc/SKS
        ///<summary>
        ///Clears a range of elements in the XArrayHelper.
        ///</summary>
        ///<param name="arr">XArrayHelper whose elements need to be cleared.</param>
        ///<param name="index">The starting index of the range of elements.</param>
        ///<param name="length">The number of elements to be cleared.</param>
        public static void Clear(XArrayHelper arr, int index, int length)
        {
            int realIndexi = arr.GetLowerBound(0);
            int realIndexj = arr.GetLowerBound(1);

            index = index - arr.GetLowerBound(0);

            while (index > 0)
            {
                if (index > arr.GetUpperBound(1))
                {
                    realIndexi = realIndexi + 1;
                    index      = index - arr.GetLength(1);
                }
                else
                {
                    realIndexj = realIndexj + index;
                    index      = 0;
                }
            }

            for (int j = realIndexj; j <= arr.GetUpperBound(1); j++)
            {
                if (length < 0)
                {
                    return;
                }
                arr[realIndexi, j] = null;
                length             = length - 1;
            }

            realIndexi = realIndexi + 1;

            for (int i = realIndexi; i <= arr.GetUpperBound(0); i++)
            {
                for (int j = arr.GetLowerBound(1); j <= arr.GetUpperBound(1); j++)
                {
                    if (length < 1)
                    {
                        return;
                    }
                    arr[i, j] = null;
                    length    = length - 1;
                }
            }
        }
예제 #4
0
파일: XArrayHelper.cs 프로젝트: xxdoc/SKS
        ///<summary>
        ///This function is a Factory to create Xarray instances.
        ///</summary>
        ///<param name="Lengths">The length of each dimension.</param>
        ///<param name="LowerBounds">The lower bounds to use for each dimension.</param>
        ///<returns>A new XArrayHelper instance.</returns>
        public static XArrayHelper CreateInstanceXarray(int[] Lengths, int[] LowerBounds)
        {
            XArrayHelper xarr = new XArrayHelper();

            xarr.DimensionLengths     = Lengths;
            xarr.DimensionLowerBounds = LowerBounds;
            for (int col = 0; col <= Lengths[1]; col++)
            {
                xarr.Columns.Add(new DataColumn());
            }

            for (int i = 0; i <= Lengths[0]; i++)
            {
                DataRow row = xarr.NewRow();
                xarr.Rows.Add(row);
            }
            return(xarr);
        }
예제 #5
0
        ///<summary>
        ///Clears a range of elements in the XArrayHelper.
        ///</summary>
        ///<param name="arr">XArrayHelper whose elements need to be cleared.</param>
        ///<param name="index">The starting index of the range of elements.</param>
        ///<param name="length">The number of elements to be cleared.</param>
        public static void Clear(XArrayHelper arr, int index, int length)
        {
            int realIndexi = arr.GetLowerBound(0);
            int realIndexj = arr.GetLowerBound(1);

            index = index - arr.GetLowerBound(0);

            while (index > 0)
            {
                if (index > arr.GetUpperBound(1))
                {
                    realIndexi = realIndexi + 1;
                    index = index - arr.GetLength(1);
                }
                else
                {
                    realIndexj = realIndexj + index;
                    index = 0;
                }
            }

            for (int j = realIndexj; j <= arr.GetUpperBound(1); j++)
            {
                if (length < 0) return;
                arr[realIndexi, j] = null;
                length = length - 1;
            }

            realIndexi = realIndexi + 1;

            for (int i = realIndexi; i <= arr.GetUpperBound(0); i++)
            {
                for (int j = arr.GetLowerBound(1); j <= arr.GetUpperBound(1); j++)
                {
                    if (length < 1) return;
                    arr[i, j] = null;
                    length = length - 1;
                }
            }
        }
예제 #6
0
 ///<summary>
 ///Creates a XArrayHelper and copies the values from a XArrayHelper.
 ///</summary>
 ///<param name="table">The source XArrayHelper to be copied.</param>
 public void LoadRows(XArrayHelper table)
 {
     this.RedimXArray(new int[] { table.GetUpperBound(0), table.GetUpperBound(1) }, new int[] { table.GetLowerBound(0), table.GetLowerBound(1) });
     for (int row = table.GetLowerBound(0); row <= table.GetUpperBound(0); row++)
     {
         for (int col = table.GetLowerBound(1); col <= table.GetUpperBound(1); col++)
         {
             this.SetValue(table.GetValue(row, col), row, col);
         }
     }
 }
예제 #7
0
 ///<summary>
 ///Creates a cleared a XArrayHelper.
 ///</summary>
 ///<param name="arr">XArrayHelper whose elements need to be cleared.</param>
 public void Clear(ref XArrayHelper arr)
 {
     int[] length = new int[] { 1, 0 };
     int[] lowerB = new int[] { arr.DimensionLowerBounds[0], arr.DimensionLowerBounds[1] };
     this.Clear();
     arr.RedimXArray(length, lowerB);
 }
예제 #8
0
        ///<summary>
        ///This function is a Factory to create Xarray instances. 
        ///</summary>
        ///<param name="Lengths">The length of each dimension.</param>
        ///<param name="LowerBounds">The lower bounds to use for each dimension.</param>
        ///<returns>A new XArrayHelper instance.</returns>
        public static XArrayHelper CreateInstanceXarray(int[] Lengths, int[] LowerBounds)
        {
            XArrayHelper xarr = new XArrayHelper();

            xarr.DimensionLengths = Lengths;
            xarr.DimensionLowerBounds = LowerBounds;
            for (int col = 0; col <= Lengths[1]; col++)
            {
                xarr.Columns.Add(new DataColumn());
            }

            for (int i = 0; i <= Lengths[0]; i++)
            {
                DataRow row = xarr.NewRow();
                xarr.Rows.Add(row);
            }
            return xarr;
        }