diff --git a/benchmark.c b/benchmark.c index 5879b28..db0b2c7 100644 --- a/benchmark.c +++ b/benchmark.c @@ -89,7 +89,7 @@ bm_pop() { } static void -bm_shift() { +bm_lpop() { int n = nnodes; list_t *list = list_new(); while (n--) { @@ -97,7 +97,7 @@ bm_shift() { } list_node_t *node; start(); - while ((node = list_shift(list))) + while ((node = list_lpop(list))) ; stop(); } @@ -134,7 +134,7 @@ main(int argc, const char **argv){ bm("rpushed", bm_rpush); bm("lpushed", bm_lpush); bm("pop", bm_pop); - bm("shift", bm_shift); + bm("lpop", bm_lpop); bm("find (last node)", bm_find); bm("iterate", bm_iterate); bm("at(100,000)", bm_at); diff --git a/src/list.c b/src/list.c index 0b7b88c..4550ba6 100644 --- a/src/list.c +++ b/src/list.c @@ -85,7 +85,7 @@ list_pop(list_t *self) { */ list_node_t * -list_shift(list_t *self) { +list_lpop(list_t *self) { if (!self->len) return NULL; list_node_t *node = self->head; if (--self->len) { diff --git a/src/list.h b/src/list.h index e27ef92..d9c5a15 100644 --- a/src/list.h +++ b/src/list.h @@ -94,7 +94,7 @@ list_node_t * list_pop(list_t *self); list_node_t * -list_shift(list_t *self); +list_lpop(list_t *self); void list_remove(list_t *self, list_node_t *node); diff --git a/test.c b/test.c index 86a0428..d57a576 100644 --- a/test.c +++ b/test.c @@ -234,7 +234,7 @@ test_list_pop() { } static void -test_list_shift() { +test_list_lpop() { // Setup list_t *list = list_new(); list_node_t *a = list_rpush(list, list_node_new("a")); @@ -244,22 +244,22 @@ test_list_shift() { // Assertions assert(3 == list->len); - assert(a == list_shift(list)); + assert(a == list_lpop(list)); assert(2 == list->len); assert(b == list->head); assert(NULL == list->head->prev && "new head node prev is not NULL"); assert(NULL == a->prev && "detached node prev is not NULL"); assert(NULL == a->next && "detached node next is not NULL"); - assert(b == list_shift(list)); + assert(b == list_lpop(list)); assert(1 == list->len); - assert(c == list_shift(list)); + assert(c == list_lpop(list)); assert(0 == list->len); assert(NULL == list->head); assert(NULL == list->tail); - assert(NULL == list_shift(list)); + assert(NULL == list_lpop(list)); assert(0 == list->len); } @@ -316,7 +316,7 @@ main(int argc, const char **argv){ test(list_at); test(list_remove); test(list_pop); - test(list_shift); + test(list_lpop); test(list_destroy); test(list_iterator_t); puts("... \x1b[32m100%\x1b[0m\n");