i looked through my notes back and front and couldnt find anything about his struct that he created, seems he just referred to it without really showing it...
so i thought id try and do a fresh insert with pre and post declarations just to get the idea of it down.. tell me what u think..
Code:
/* SLLinsert: inserts a new entry into the list
* Pre conditions: The list created, not full, x is a valid list entry, p is a valid position
* Post conditions: x has successfully been inserted into position p in list
*/
void SLLinsert(Position p, ListEntry x, List *list) {
ListNode *newNode, *current;
if (p < 0 || p > list->count)
Error("Attempt to insert in a position not in the list.");
else {
newNode = MakeListNode(x);
if (p == 0) {
newNode->next = list->head;
list->head = newNode;
}
else {
SetPosition(p-1, list, ¤t);
newNode->next = current->next;
current->next = newNode;
}
list->count++;
}
}