Beispiel #1
0
        /// <summary>
        /// Sort the result.
        /// If AMakeFlatTable is false, then it only sorts the children of the same parent line.
        /// Otherwise it sorts all lines but the result will be that all children have the same parent line.
        /// First column has higher precedence, so the sorting starts with the last column
        /// </summary>
        /// <param name="AColumns">comma separated list of integers, describing the columns that the sorting should be based upon</param>
        /// <param name="AMakeFlatTable">Indicator if we should make a flat table. This allows sorting with multiple levels</param>
        /// <returns>void</returns>
        public void Sort(String AColumns, Boolean AMakeFlatTable)
        {
            TRowComparer RowComparer;

            RowComparer = new TRowComparer(AColumns, AMakeFlatTable);

            /* idea for sorting:
             * for each master
             * collect its children in an Arraylist
             * sort the list by all given columns
             * negate all master and child numbers in the results array;
             *  that is to avoid to not being able to differ
             *  between already renamed rows and still to be done rows
             * get a range of valid numbers from the minimum and maximum of the to be sorted children
             * for each child, give it a new valid number, according to the new position
             * change all rows reporting to that row accordingly
             * after that has been done, change all the other negated numbers back
             */
            if (results.Count < 1)
            {
                return;
            }

            this.results.Sort(0, results.Count, RowComparer);

            if (AMakeFlatTable)
            {
                foreach (TResult row in results)
                {
                    row.childRow = results.IndexOf(row) + 1;
                    // make a flat table
                    row.masterRow = 0;
                }
            }
            else
            {
                foreach (TResult row in results)
                {
                    row.childRow = results.IndexOf(row) + 1;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sort the result.
        /// If AMakeFlatTable is false, then it only sorts the children of the same parent line.
        /// Otherwise it sorts all lines but the result will be that all children have the same parent line.
        /// First column has higher precedence, so the sorting starts with the last column
        /// </summary>
        /// <param name="AColumns">comma separated list of integers, describing the columns that the sorting should be based upon</param>
        /// <param name="AMakeFlatTable">Indicator if we should make a flat table. This allows sorting with multiple levels</param>
        /// <returns>void</returns>
        public void Sort(String AColumns, Boolean AMakeFlatTable)
        {
            TRowComparer RowComparer;

            RowComparer = new TRowComparer(AColumns, AMakeFlatTable);

            /* idea for sorting:
             * for each master
             * collect its children in an Arraylist
             * sort the list by all given columns
             * negate all master and child numbers in the results array;
             *  that is to avoid to not being able to differ
             *  between already renamed rows and still to be done rows
             * get a range of valid numbers from the minimum and maximum of the to be sorted children
             * for each child, give it a new valid number, according to the new position
             * change all rows reporting to that row accordingly
             * after that has been done, change all the other negated numbers back
             */
            if (results.Count < 1)
            {
                return;
            }

            this.results.Sort(0, results.Count, RowComparer);

            if (AMakeFlatTable)
            {
                foreach (TResult row in results)
                {
                    row.childRow = results.IndexOf(row) + 1;
                    // make a flat table
                    row.masterRow = 0;
                }
            }
            else
            {
                foreach (TResult row in results)
                {
                    row.childRow = results.IndexOf(row) + 1;
                }
            }
        }