Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void insertNodeAt(List* myList, Node* myNode, int pos) {
- Node* insertBefore = myList->head;
- for (int p = 0; p < pos && insertBefore != NULL; p++) insertBefore = insertBefore->next;
- if (insertBefore != NULL) {
- if (pos > 0) insertBefore->previous->next = myNode;
- insertBefore->previous = myNode;
- }
- if (pos == 0) myList->head = myNode;
- if (pos == myList->counter) myList->tail = myNode;
- myList->counter++;
- }
Advertisement
Add Comment
Please, Sign In to add comment