/* adlist.c - A generic doubly linked list implementation
*
- * Copyright (c) 2006-2009, Salvatore Sanfilippo <antirez at gmail dot com>
+ * Copyright (c) 2006-2010, Salvatore Sanfilippo <antirez at gmail dot com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
}
/* Returns a list iterator 'iter'. After the initialization every
- * call to listNextElement() will return the next element of the list.
+ * call to listNext() will return the next element of the list.
*
* This function can't fail. */
listIter *listGetIterator(list *list, int direction)
zfree(iter);
}
+/* Create an iterator in the list private iterator structure */
+void listRewind(list *list, listIter *li) {
+ li->next = list->head;
+ li->direction = AL_START_HEAD;
+}
+
+void listRewindTail(list *list, listIter *li) {
+ li->next = list->tail;
+ li->direction = AL_START_TAIL;
+}
+
/* Return the next element of an iterator.
* It's valid to remove the currently returned element using
* listDelNode(), but not to remove other elements.
* }
*
* */
-listNode *listNextElement(listIter *iter)
+listNode *listNext(listIter *iter)
{
listNode *current = iter->next;
copy->free = orig->free;
copy->match = orig->match;
iter = listGetIterator(orig, AL_START_HEAD);
- while((node = listNextElement(iter)) != NULL) {
+ while((node = listNext(iter)) != NULL) {
void *value;
if (copy->dup) {
listNode *node;
iter = listGetIterator(list, AL_START_HEAD);
- while((node = listNextElement(iter)) != NULL) {
+ while((node = listNext(iter)) != NULL) {
if (list->match) {
if (list->match(node->value, key)) {
listReleaseIterator(iter);