42#include "lib/dbl-list.h"
74 for(
this = *dll; this->next != NULL;
this = this->next);
82 struct dll *
this, *previous, *next;
84 if(*dll == NULL || element == NULL) {
88 for(
this = *dll;
this != NULL;
this = this->next) {
90 previous = this->previous;
94 previous->next = this->next;
98 next->previous = this->previous;
115 if(element == NULL) {
124 ((
struct dll *)element)->previous = NULL;
125 ((
struct dll *)element)->next = head;
129 head->previous = element;
140 if(element == NULL) {
153 tail->next = element;
156 ((
struct dll *)element)->previous = tail;
157 ((
struct dll *)element)->next = NULL;
163 if(element == NULL || existing == NULL) {
170 ((
struct dll *)element)->next = ((
struct dll *)existing)->next;
171 ((
struct dll *)element)->previous = existing;
173 if(((
struct dll *)existing)->next) {
174 ((
struct dll *)existing)->next->previous = element;
176 ((
struct dll *)existing)->next = element;
182 if(element == NULL || existing == NULL) {
189 ((
struct dll *)element)->next = existing;
190 ((
struct dll *)element)->previous = ((
struct dll *)existing)->previous;
192 if(((
struct dll *)existing)->previous) {
193 ((
struct dll *)existing)->previous->next = element;
195 ((
struct dll *)existing)->previous = element;
198 if(*dll == existing) {
206 unsigned long len = 0;
213 for(
this = *dll;
this != NULL;
this = this->next) {
223 return *dll == NULL ? true :
false;
void dbl_list_add_after(dbl_list_t dll, void *existing, void *element)
Add an element to a doubly linked list after an existing element.
unsigned long dbl_list_length(const_dbl_list_t dll)
Get the length of a doubly-linked list.
void * dbl_list_tail(const_dbl_list_t dll)
Return the tail of a doubly-linked list.
void ** dbl_list_t
The doubly-linked list datatype.
void dbl_list_add_head(dbl_list_t dll, void *element)
Add an element to the head of a doubly-linked list.
void dbl_list_add_before(dbl_list_t dll, void *existing, void *element)
Add an element to a doubly linked list before an existing element.
void dbl_list_add_tail(dbl_list_t dll, void *element)
Add an element to the tail of a doubly-linked list.
void * dbl_list_head(const_dbl_list_t dll)
Return the tail of a doubly-linked list.
void dbl_list_remove(dbl_list_t dll, const void *element)
Remove an element from a doubly-linked list.
void dbl_list_init(dbl_list_t dll)
Initialise a doubly-linked list.
void *const * const_dbl_list_t
The non-modifiable doubly-linked list type.
bool dbl_list_is_empty(const_dbl_list_t dll)
Determine whether a doubly-linked list is empty.