Esempio n. 1
0
        public void randomSortAllStudents(StudentList usedStudentList = null)
        {
            if (usedStudentList == null)
            {
                usedStudentList = getStudentListFromSeatList();
            }
            updateSize();
            if (usedStudentList.students.Count != size)
            {
                throw new Exception("Size miss matched");
            }
            usedStudentList.resetAllUnused();
            Seat i = head;

            foreach (int r in col)
            {
                for (int j = 0; j < r; j++)
                {
                    i.stu = usedStudentList.retrieveOneRandomUnused();
                    i     = i.next;
                }
            }
        }
Esempio n. 2
0
        public void randomSortAllStudentsWithExchange()
        {
            StudentList temp = getStudentListFromSeatList();

            updateSize();
            if (temp.students.Count != size)
            {
                throw new Exception("Size miss matched");
            }
            temp.resetAllUnused();

            StudentList front = StudentList.getHalf(temp, false);
            StudentList back  = StudentList.getHalf(temp, true);

            Seat i          = head;
            int  frontIndex = 0;
            int  backIndex  = 0;

            foreach (int r in col)
            {
                for (int j = 0; j < r; j++)
                {
                    if (frontIndex < front.students.Count)
                    {
                        i.stu = front.retrieveOneRandomUnused();
                        i     = i.next;
                        frontIndex++;
                    }
                    else
                    {
                        i.stu = back.retrieveOneRandomUnused();
                        i     = i.next;
                        backIndex++;
                    }
                }
            }
        }