Ejemplo n.º 1
0
        public static StudentList combineTwo(StudentList input1, StudentList input2)
        {
            List <Student> temp = new List <Student>();

            foreach (Student i in input1.students)
            {
                temp.Add(i);
            }
            foreach (Student i in input2.students)
            {
                temp.Add(i);
            }
            return(new StudentList(temp));
        }
Ejemplo n.º 2
0
        public static StudentList getHalf(StudentList input, bool first = true)
        {
            List <Student> temp = new List <Student>();

            if (first)
            {
                for (int i = 0; i < input.students.Count / 2; i++)
                {
                    temp.Add(input.students[i]);
                }
            }
            else
            {
                for (int i = input.students.Count / 2; i < input.students.Count; i++)
                {
                    temp.Add(input.students[i]);
                }
            }
            return(new StudentList(temp));
        }
Ejemplo n.º 3
0
        public void nonrandomSortAllStudents(StudentList usedStudentList)
        {
            updateSize();
            if (usedStudentList.students.Count != size)
            {
                throw new Exception("Size miss matched");
            }
            usedStudentList.resetAllUnused();
            Seat i = head;
            int  k = 0;

            foreach (int r in col)
            {
                for (int j = 0; j < r; j++)
                {
                    i.stu = usedStudentList.students[k];
                    i     = i.next;
                    k++;
                }
            }
        }
Ejemplo n.º 4
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;
                }
            }
        }
Ejemplo n.º 5
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++;
                    }
                }
            }
        }