Created
March 22, 2015 21:33
-
-
Save reportbase/69d6626c9389a63d921e to your computer and use it in GitHub Desktop.
reverse array
This file contains hidden or 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
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