Ejemplo n.º 1
0
        private static int Partition(string sortBy, List <Lesson> arr, int left, int right, bool MinToMax)
        {
            Lesson pivot = arr[right];
            Lesson temp;

            int i = left;

            for (int j = left; j < right; j++)
            {
                switch (sortBy.ToLower())
                {
                case "year":
                    if ((MinToMax && arr[j].year <= pivot.year) || (!MinToMax && arr[j].year > pivot.year))
                    {
                        temp   = arr[j];
                        arr[j] = arr[i];
                        arr[i] = temp;
                        i++;
                    }
                    break;

                case "type":
                    if ((MinToMax && arr[j].type.CompareTo(pivot.type) <= 0) || (!MinToMax && arr[j].type.CompareTo(pivot.type) > 0))
                    {
                        temp   = arr[j];
                        arr[j] = arr[i];
                        arr[i] = temp;
                        i++;
                    }
                    break;

                case "course":
                    if ((MinToMax && arr[j].courseName.CompareTo(pivot.courseName) <= 0) || (!MinToMax && arr[j].courseName.CompareTo(pivot.courseName) > 0))
                    {
                        temp   = arr[j];
                        arr[j] = arr[i];
                        arr[i] = temp;
                        i++;
                    }
                    break;

                case "lecturer":
                    if ((MinToMax && arr[j].lecturer.CompareTo(pivot.lecturer) <= 0) || (!MinToMax && arr[j].lecturer.CompareTo(pivot.lecturer) > 0))
                    {
                        temp   = arr[j];
                        arr[j] = arr[i];
                        arr[i] = temp;
                        i++;
                    }
                    break;

                case "day":
                    if ((MinToMax && arr[j].getShortDay().CompareTo(pivot.getShortDay()) <= 0) || (!MinToMax && arr[j].getShortDay().CompareTo(pivot.getShortDay()) > 0))
                    {
                        temp   = arr[j];
                        arr[j] = arr[i];
                        arr[i] = temp;
                        i++;
                    }
                    break;

                case "start":
                    if ((MinToMax && arr[j].start <= pivot.start) || (!MinToMax && arr[j].start > pivot.start))
                    {
                        temp   = arr[j];
                        arr[j] = arr[i];
                        arr[i] = temp;
                        i++;
                    }
                    break;

                case "end":
                    if ((MinToMax && arr[j].end <= pivot.end) || (!MinToMax && arr[j].end > pivot.end))
                    {
                        temp   = arr[j];
                        arr[j] = arr[i];
                        arr[i] = temp;
                        i++;
                    }
                    break;

                case "hours":
                    if ((MinToMax && arr[j].weekHour <= pivot.weekHour) || (!MinToMax && arr[j].weekHour > pivot.weekHour))
                    {
                        temp   = arr[j];
                        arr[j] = arr[i];
                        arr[i] = temp;
                        i++;
                    }
                    break;

                case "class":
                    if ((MinToMax && arr[j].className.CompareTo(pivot.className) <= 0) || (!MinToMax && arr[j].className.CompareTo(pivot.className) > 0))
                    {
                        temp   = arr[j];
                        arr[j] = arr[i];
                        arr[i] = temp;
                        i++;
                    }
                    break;

                default:
                    if ((MinToMax && arr[j].year <= pivot.year) || (!MinToMax && arr[j].year > pivot.year))
                    {
                        temp   = arr[j];
                        arr[j] = arr[i];
                        arr[i] = temp;
                        i++;
                    }
                    break;
                }
            }

            arr[right] = arr[i];
            arr[i]     = pivot;

            return(i);
        }
Ejemplo n.º 2
0
 public bool collisionAfter(Lesson lsn)
 {
     return(this.getShortDay().CompareTo(lsn.getShortDay()) == 0 &&
            this.start >= lsn.start && this.start < lsn.end);
 }
Ejemplo n.º 3
0
 public bool After(Lesson lsn)
 {
     return((this.getShortDay().CompareTo(lsn.getShortDay()) > 0) ||
            (this.getShortDay().CompareTo(lsn.getShortDay()) == 0 &&
             this.start >= lsn.end));
 }
Ejemplo n.º 4
0
 public bool collisionBefore(Lesson lsn)
 {
     return(this.getShortDay().CompareTo(lsn.getShortDay()) == 0 &&
            this.start <= lsn.start && this.end > lsn.start);
 }
Ejemplo n.º 5
0
 public bool Before(Lesson lsn)
 {
     return((this.getShortDay().CompareTo(lsn.getShortDay()) < 0) ||
            (this.getShortDay().CompareTo(lsn.getShortDay()) == 0 &&
             this.end <= lsn.start));
 }