#include "grouplist.h" // ******** Group List Element ********** groupListElement::groupListElement(char *groupName, groupListElementPointer oldList) { thisGroup = strdup(groupName); next = oldList; } groupListElement::~groupListElement() { delete thisGroup; } // ********* Group list ****************** groupList::groupList() { num = 0; next = NULL; last = NULL; } void groupList::addGroup(char *groupName) { if (num == 0) { last = next = new groupListElement(groupName, NULL); } else { groupListElementPointer newG = new groupListElement(groupName, NULL); last->next = newG; last = newG; } num++; } char *groupList::nextGroup() { groupListElementPointer old = next; next = next->next; char *ret = strdup(old->thisGroup); delete old; num--; if (num == 0) last = NULL; return ret; } int groupList::numGroups() { return num; }