Skip to content

Instantly share code, notes, and snippets.

@slembcke
Created July 22, 2010 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slembcke/486214 to your computer and use it in GitHub Desktop.
Save slembcke/486214 to your computer and use it in GitHub Desktop.
// iterating a singly linked list ring
// operations might include splicing or deleting elements
node *elt = first, *next;
do {
next = elt->next;
// do stuff here including modify elt->next
} while((elt = next) != first);
// is there a less verbose way?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment