#include #include #include "util.h" #include "list.h" void list_init(list *l) { assert(l); memset(l, 0, sizeof(*l)); } static inline list_node * list_node_orphan(list_node *li) { li->next = NULL; li->prev = NULL; return li; } //NOTE: Можем ли мы расчитывать на то, что node->next валидно после вызова list_free_cb??? void list_clear(list *l, list_free_cb cb) { assert(l); // } void list_push_front(list *l, list_node *item) { assert(l && item); // } void list_push_back(list *l, list_node *item) { assert(l && item); // } list_node * list_first(list *l) { assert(l); return l->head; } list_node * list_last(list *l) { assert(l); return l->tail; } size_t list_len(list *l) { assert(l); // return 0; } list_node * list_get(list *l, int idx) { assert(l); // return NULL; } void list_insert(list *l, list_node *item, int idx) { assert(l && item); // } list_node * list_pop_front(list *l) { assert(l); // return NULL; } list_node * list_pop_back(list *l) { assert(l); // return NULL; } int list_index(list *l, list_node *n) { assert(l && n); list_node *tmp; int i = 0; for (tmp = l->head; tmp != NULL; tmp = tmp->next) { if (tmp == n) return i; i++; } return -1; } list_node * list_remove(list *l, int idx) { assert(l); // return NULL; } void list_reverse(list *l) { assert(l); // } void list_pass(list *l, list_pass_cb cb, void *opaq) { struct list_node *iter; list_for_each(iter, l) { cb(iter, opaq); } }