Created
May 29, 2013 09:43
-
-
Save robbinhan/5669167 to your computer and use it in GitHub Desktop.
链表迭代的代码写法
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
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