// make a physical copy of a list // new list looks identical to original list IntList IntListCopy(IntList L) { struct IntListRep *Lnew; struct IntListNode *curr; Lnew = newIntList(); for (curr = L->first; curr != NULL; curr = curr->next) IntListInsert(Lnew, curr->data); return Lnew; }
// create an IntList by reading values from a file // assume that the file is open for reading IntList getIntList(FILE *inf) { IntList L; int v; L = newIntList(); while (fscanf(inf,"%d",&v) != EOF) IntListInsert(L,v); return L; }
// insert an integer into correct place in a sorted list void IntListInsertInOrder(IntList L, int v) { // This is INCORRECT IntListInsert(L, v); }