Example #1
0
        public void Create(Report report, TypeOfSort sortType)
        {
            switch (sortType)
            {
            case TypeOfSort.SortByCallType:
                repo = SortByCallType(report);
                break;

            case TypeOfSort.SortByDate:
                repo = SortByDate(report);
                break;

            case TypeOfSort.SortByCost:
                repo = SortByCost(report);
                break;

            case TypeOfSort.SortByNumber:
                repo = SortByNumber(report);
                break;
            }

            foreach (var item in repo)
            {
                Console.WriteLine("=> {0}, {1}, {2}, opponent: {3}, price: {4}",
                                  item.CallType,
                                  item.Time.ToString("mm:ss"),
                                  item.Date,
                                  item.Number,
                                  decimal.Round(item.Cost, 2));
            }
        }
Example #2
0
        /// <summary>
        /// Основной метод сортировки пузырьком.
        /// </summary>
        /// <param name="array">Входной зубчатый массив.</param>
        /// <param name="type">Переменная типа TypeOfSort для определения критерия сортировки.</param>
        /// <param name="comparer">Переменная типа IComparer для определения направления сортировки, по умолчанию по возрастанию.</param>
        /// <returns>Возвращает отсортированный зубчатый массив.</returns>
        public static int[][] BubbleSort(this int[][] array, TypeOfSort type = TypeOfSort.Sum, IComparer comparer = null)
        {
            if (comparer == null)
            {
                comparer = SortAsq();
            }

            var result = array;

            switch (type)
            {
            case TypeOfSort.Sum:
                result = BubbleSortSum(array, comparer);
                break;

            case TypeOfSort.Min:
                result = BubbleSortMin(array, comparer);
                break;

            case TypeOfSort.Max:
                result = BubbleSortMax(array, comparer);
                break;
            }

            return(result);
        }
        static void SortArray(double[] array, TypeOfSort type)
        {
            double tmp;

            switch (type)
            {
            case TypeOfSort.Ascending:
            {
                for (int j = 0; j < array.Length - 1; j++)
                {
                    for (int i = 1; i < array.Length; i++)
                    {
                        if (array[i] < array[i - 1])
                        {
                            tmp          = array[i - 1];
                            array[i - 1] = array[i];
                            array[i]     = tmp;
                        }
                    }
                }

                break;
            }

            case TypeOfSort.Descending:
            {
                for (int j = 0; j < array.Length - 1; j++)
                {
                    for (int i = 1; i < array.Length; i++)
                    {
                        if (array[i] > array[i - 1])
                        {
                            tmp          = array[i - 1];
                            array[i - 1] = array[i];
                            array[i]     = tmp;
                        }
                    }
                }
                break;
            }

            default: break;
            }
        }
Example #4
0
        /// <summary>
        /// Основной метод сортировки пузырьком.
        /// </summary>
        /// <param name="array">Входной зубчатый массив.</param>
        /// <param name="type">Переменная типа TypeOfSort для определения критерия сортировки.</param>
        /// <param name="comparer">Переменная типа IComparer для определения направления сортировки, по умолчанию по возрастанию.</param>
        /// <returns>Возвращает отсортированный зубчатый массив.</returns>
        public static int[][] BubbleSort(this int[][] array, TypeOfSort type = TypeOfSort.Sum, IComparer comparer = null)
        {
            if (comparer == null)
            {
                comparer = SortAsq();
            }

            switch (type)
            {
            case TypeOfSort.Sum:
                return(BSortHandler(array, BubbleSortDelegate.BSortSumHandler, comparer));

            case TypeOfSort.Min:
                return(BSortHandler(array, BubbleSortDelegate.BSortMinHandler, comparer));

            case TypeOfSort.Max:
                return(BSortHandler(array, BubbleSortDelegate.BSortMaxHandler, comparer));

            default:
                return(array);
            }
        }
Example #5
0
        // По убыванию
        public static void SortByProgress(TypeOfSort ourTypeOfSort)
        {
            Student[] ourStudentArray = journal.ToArray();

            Array.Sort(ourStudentArray);

            switch (ourTypeOfSort)
            {
            case TypeOfSort.Increase:
            {
            }
            break;

            case TypeOfSort.Decrease:
            {
                Array.Reverse(ourStudentArray);
            }
            break;
            }

            ShowAll(ourStudentArray);
        }
Example #6
0
        public IEnumerable <RecordOfReport> SortCalls(Report report, TypeOfSort typeOfSort)
        {
            var tempReport = report.GetRecords();

            switch (typeOfSort)
            {
            case TypeOfSort.SortByTypeOfCall:
                return(tempReport = tempReport.OrderBy(x => x.TypeOfCall).ToList());

            case TypeOfSort.SortByDate:
                return(tempReport = tempReport.OrderBy(x => x.Date).ToList());

            case TypeOfSort.SortByAmount:
                return(tempReport = tempReport.OrderBy(x => x.Amount).ToList());

            case TypeOfSort.SortByNumber:
                return(tempReport = tempReport.OrderBy(x => x.Number).ToList());

            default:
                return(tempReport);
            }
        }
Example #7
0
        public static void SortByWorkExperience(TypeOfSort ourtypeOfSort)
        {
            Employee[] ourEmployeeArray = journal.ToArray();

            Array.Sort(ourEmployeeArray);

            switch (ourtypeOfSort)
            {
            case TypeOfSort.Increase:
            {
            }
            break;

            case TypeOfSort.Decrease:
            {
                Array.Reverse(ourEmployeeArray);
            }
            break;
            }

            ShowAll();
        }
Example #8
0
 private void SetSortSettings(MainCoordinate mainCoordinate, TypeOfSort firstObjectX, TypeOfSort firstObjectY)
 {
     mainLine          = mainCoordinate;
     this.firstObjectX = firstObjectX;
     this.firstObjectY = firstObjectY;
 }
Example #9
0
 public void Sort <T>(MainCoordinate mainCoordinate, TypeOfSort firstObjectX, TypeOfSort firstObjectY, T[] GameObjects, Func <T, Vector3> getPosition) where T : MonoBehaviour
 {
     SetSortSettings(mainCoordinate, firstObjectX, firstObjectY);
     Sort(GameObjects, getPosition);
 }
Example #10
0
 public void Sort(MainCoordinate mainCoordinate, TypeOfSort firstObjectX, TypeOfSort firstObjectY, GameObject[] places)
 {
     SetSortSettings(mainCoordinate, firstObjectX, firstObjectY);
     Sort(places, x => x.transform.position);
 }
Example #11
0
 public void SetTypeOfSort(TypeOfSort t)
 {
     typeOfSort = t;
 }