Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

shift -> lpop

  • Loading branch information...
commit 3240b6d497f1bbe9a668d18b76a97e12d7626027 1 parent ff0b832
@tj tj authored
Showing with 11 additions and 11 deletions.
  1. +3 −3 benchmark.c
  2. +1 −1  src/list.c
  3. +1 −1  src/list.h
  4. +6 −6 test.c
View
6 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);
View
2  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) {
View
2  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);
View
12 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");
Please sign in to comment.
Something went wrong with that request. Please try again.