Created
October 18, 2010 02:59
-
-
Save swanson/631639 to your computer and use it in GitHub Desktop.
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 queue_swap(event_t *a, event_t *b) | |
{ | |
event_t *tmp; | |
// make sure the parent links are updated to point to the new children | |
if (a->parent && a->parent->left == a) | |
{ | |
a->parent->left = b; | |
} | |
else if (a->parent) | |
{ | |
a->parent->right = b; | |
} | |
if (b->parent && b->parent->left == b) | |
{ | |
b->parent->left = a; | |
} | |
else if (b->parent) | |
{ | |
b->parent->right = a; | |
} | |
tmp = a->left; | |
a->left = b->left; | |
b->left = tmp; | |
tmp = a->right; | |
a->right = b->right; | |
b->right = tmp; | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment