#include #include #include #include "ClassList.h" StudentNode* head; StudentNode* tail; int numStudents; void InitializeList() { head = NULL; tail = NULL; numStudents = 0; } int GetCount() { return numStudents; } StudentNode* CreateNode (Student* aStudent) { StudentNode* temp = (StudentNode*) malloc (sizeof (StudentNode)); temp->data = aStudent; temp->next = NULL; return temp; } void DestroyNode (StudentNode* aNode) { DestroyStudent (aNode->data); free (aNode); } void EmptyList() { StudentNode* currNode; StudentNode* nextNode; currNode = head; while (currNode != NULL) { nextNode = currNode->next; DestroyNode (currNode); currNode = nextNode; } InitializeList(); } void Prepend (Student* aStudent) { StudentNode* newNode = CreateNode (aStudent); if (head == NULL) { /* List is empty */ head = newNode; tail = newNode; } else { newNode->next = head; head = newNode; } ++numStudents; } void Append (Student* aStudent) { StudentNode* newNode = CreateNode (aStudent); if (head == NULL) { /* List is empty */ head = newNode; tail = newNode; } else { tail->next = newNode; tail = newNode; } ++numStudents; } void Insert (int position, Student* aStudent) { /* Variable declarations go here */ /* This assert statement checks the pre-condition. */ assert (position > 0 && position <= numStudents + 1); /* Add the statements to do the insert here. */ /* Don't forget to increment numStudents. */ } void Delete (int position) { /* Complete this function. */ /* Don't forget to check the pre-condition, */ /* destroy the deleted node, and decrement */ /* numStudents. */ } int Find (long idNum) { /* Complete this function */ } void PrintList() { StudentNode* currNode; currNode = head; while (currNode != NULL) { PrintStudent (currNode->data); currNode = currNode->next; } } void DumpList() { /* Complete this function. */ /* Hint: Use %p with printf() to print addresses. */ }