Created
December 6, 2014 17:34
-
-
Save LizardLeliel/1d150836b17c9047ca2c to your computer and use it in GitHub Desktop.
Just a snippit to show someone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void pushSortedAdjNode(adjNode** listHead, int newID, int newDistance) { | |
adjNode* newNode = malloc(sizeof(adjNode)); | |
newNode->id = newID; | |
newNode->distance = newDistance; | |
if (*listHead == NULL || (*listHead)->distance >= newDistance) { | |
newNode->next = *listHead; | |
*listHead = newNode; | |
return; | |
} | |
adjNode* temp = *listHead; | |
while ((*listHead)->next != NULL && (*listHead)->next->distance <= newDistance) { | |
*listHead = (*listHead)->next; | |
} | |
newNode->next = (*listHead)->next; | |
(*listHead)->next = newNode; | |
*listHead = temp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment