// appends element to list and returns new tail linked_list_t* list_insert_tail(linked_list_t* head, void* data) { linked_list_t* node = malloc(sizeof(linked_list_t)); node->next = NULL; node->prev = list_get_tail(head); node->data = data; return node; }
int list_pop_back(List* l) { ListNode *last;; if (list_is_empty(l)) return 0; last = list_get_tail(l); list_free_node(last); return 1; }
ListNode *list_add_node(ListNode *list_node, ListNode *user_list_node) { ListNode *new_list_node, *last_list_node; if (list_node == 0 || user_list_node == 0) { return 0; } last_list_node = list_get_tail(list_node); last_list_node->next = user_list_node; user_list_node->prev = last_list_node; user_list_node->next = 0; return user_list_node; }
void *list_get(list_t list, int index){ if (!list || index < 0) return NULL; if (index == 0) return list_get_head(list); if (index == list->len-1) return list_get_tail(list); struct list_node *p = list->head; for (int i = 0; i < index; i++) p = p->next; return p->data; }
int list_push_back(List *l, int data) { ListNode *node; ListNode *last = list_get_tail(l); if (!last) return list_push_front(l, data); node = list_create_node(data, NULL, last); if (!node) return 0; return 1; }
int list_push_back(List *l, int data) { ListNode *node; ListNode *last = list_get_tail(l); int pos; if (!last) return list_push_front(l, data); node = list_create_node(l, data, -1, &pos); if (!node) return 0; last->next = pos; ++l->total; return 1; }
void list_join (void **list1, void **list2) { struct list_head *tail1, *head2; ASSERT (list_is_head (list1)); ASSERT (list_is_head (list2)); tail1 = (struct list_head *) list_get_tail (list1); if (tail1 == NULL) { *list1 = *list2; return; } tail1->next = LIST_HEAD (*list2); }
struct list* list_insert_back(struct list* l, int x, int y, s_type type, void* data) { struct list* l_or = l; struct list* l_new = malloc( sizeof(*l_new) ); l_new->data = data; l_new->x = x; l_new->y = y; l_new->type = type; l_new->next = NULL; if( l != NULL ){ l = list_get_tail(l); l->next = l_new; } else { l_or = l_new; } return l_or; }