Skip to content

Instantly share code, notes, and snippets.

@swanson
Created October 18, 2010 02:59
Show Gist options
  • Save swanson/631639 to your computer and use it in GitHub Desktop.
Save swanson/631639 to your computer and use it in GitHub Desktop.
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