Skip to content

Instantly share code, notes, and snippets.

@reportbase
Created March 22, 2015 21:33
Show Gist options
  • Save reportbase/69d6626c9389a63d921e to your computer and use it in GitHub Desktop.
Save reportbase/69d6626c9389a63d921e to your computer and use it in GitHub Desktop.
reverse array
template <typename node_t> inline
void reverse(node_t** head)
{
node_t* prev = 0;
while(*head)
{
node_t* next = (*head)->next;
(*head)->next = prev;
prev = *head;
*head = next;
}
*head = prev;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment