#include "ins_course_list.h" InsCourseList :: InsCourseList () : List() {} InsCourseList :: InsCourseList (const InsCourseList& i) : List(i) {} InsCourseList :: ~InsCourseList () {} InsCoursePref* InsCourseList :: ListIter () { return (InsCoursePref*)List::ListIter(); } void InsCourseList :: Add (const InsCoursePref& i) { InsCoursePref* ptr = (InsCoursePref*)ResetCurrent(); while (ptr != NULL) { if (*ptr == i) { ptr->SetWeight(i.GetWeight()); break; } ptr = ListIter(); } if (ptr == NULL) *this += i; } Boolean InsCourseList :: Delete (const InsCoursePref& i) { InsCoursePref* ptr = (InsCoursePref*)ResetCurrent() ; while(ptr != NULL) { if (*ptr == i) { DeleteCurrent(); return TRUE; } ptr = ListIter(); } return FALSE; } void InsCourseList :: SortByWeight () { InsCoursePref* cur = (InsCoursePref*)ResetCurrent() ; InsCoursePref* ptr = cur ; InsCoursePref* min ; while (cur != NULL) { ptr = cur; min = cur; while (ptr != NULL) { if( (ptr->GetWeight()) < (min->GetWeight()) ) min = ptr; ptr = (InsCoursePref*)ptr->GetNext(); } if (min != cur) { ptr = (InsCoursePref*)min->copy(); min->operator=(*cur); cur->operator=(*ptr); } cur = ListIter(); } } void InsCourseList :: operator= (const InsCourseList& icl) { delete head; InsCourseList* new_list = new InsCourseList(icl); head = new_list->head; tail = new_list->tail; }