src/linked_list.c

changeset 457
8f7d3fe9ca40
parent 456
227c2eabbef8
child 466
28bc3e10ac28
equal deleted inserted replaced
456:227c2eabbef8 457:8f7d3fe9ca40
107 107
108 static cx_linked_list_node *cx_ll_node_at(cx_linked_list *list, size_t index) { 108 static cx_linked_list_node *cx_ll_node_at(cx_linked_list *list, size_t index) {
109 if (index >= list->base.size) { 109 if (index >= list->base.size) {
110 return NULL; 110 return NULL;
111 } else if (index > list->base.size / 2) { 111 } else if (index > list->base.size / 2) {
112 return cx_linked_list_at(list->end, list->base.size, CX_LL_LOC_PREV, index); 112 return cx_linked_list_at(list->end, list->base.size-1, CX_LL_LOC_PREV, index);
113 } else { 113 } else {
114 return cx_linked_list_at(list->begin, 0, CX_LL_LOC_NEXT, index); 114 return cx_linked_list_at(list->begin, 0, CX_LL_LOC_NEXT, index);
115 } 115 }
116 } 116 }
117 117

mercurial