src/adlist.c
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;
}
/* Return the element at the specified zero-based index
 * where 0 is the head, 1 is the element next to head
 * and so on. Negative integers are used in order to count
 * from the tail, -1 is the last element, -2 the penultimate
 * and so on. If the index is out of range NULL is returned. */
Return the element at the specified zero-based index
where 0 is the head, 1 is the element next to head
and so on. Negative integers are used in order to count
from the tail, -1 is the last element, -2 the penultimate
and so on. If the index is out of range NULL is returned.
Return the element at the specified zero - based index where 0 is the head 1 is the element next to head and so on . Negative integers are used in order to count from the tail - 1 is the last element - 2 the penultimate and so on . If the index is out of range NULL is returned .
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;
}
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 ; }
Return the element at the specified zero-based index
 where 0 is the head, 1 is the element next to head
 and so on.
Return the element at the specified zero - based index where 0 is the head 1 is the element next to head and so on .