Skip to content

Instantly share code, notes, and snippets.

@robbinhan
Created May 29, 2013 09:43
Show Gist options
  • Save robbinhan/5669167 to your computer and use it in GitHub Desktop.
Save robbinhan/5669167 to your computer and use it in GitHub Desktop.
链表迭代的代码写法
listNode *listIndex(list *list, long index) {
listNode *n;
if (index < 0) {
index = (-index)-1;
n = list->tail;
while(index-- && n) n = n->prev;
} else {
n = list->head;
while(index-- && n) n = n->next;
}
return n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment