.TH "wl_list" 3 "Sun Mar 4 2018" "Version 1.12.0" "Wayland" \" -*- nroff -*- .ad l .nh .SH NAME wl_list \- doubly-linked list .SH SYNOPSIS .br .PP .PP \fC#include \fP .SS "Data Fields" .in +1c .ti -1c .RI "struct \fBwl_list\fP * \fBprev\fP" .br .ti -1c .RI "struct \fBwl_list\fP * \fBnext\fP" .br .in -1c .SH "Detailed Description" .PP doubly-linked list The list head is of 'struct wl_list' type, and must be initialized using \fBwl_list_init()\fP\&. All entries in the list must be of the same type\&. The item type must have a 'struct wl_list' member\&. This member will be initialized by \fBwl_list_insert()\fP\&. There is no need to call \fBwl_list_init()\fP on the individual item\&. To query if the list is empty in O(1), use \fBwl_list_empty()\fP\&. .PP Let's call the list reference 'struct wl_list foo_list', the item type as 'item_t', and the item member as 'struct wl_list link'\&. .PP The following code will initialize a list: .PP .nf struct wl_list foo_list; struct item_t { int foo; struct wl_list link; }; struct item_t item1, item2, item3; wl_list_init(&foo_list); wl_list_insert(&foo_list, &item1\&.link); // Pushes item1 at the head wl_list_insert(&foo_list, &item2\&.link); // Pushes item2 at the head wl_list_insert(&item2\&.link, &item3\&.link); // Pushes item3 after item2 .fi .PP .PP The list now looks like [item2, item3, item1] .PP Iterate the list in ascending order: .PP .nf item_t *item; wl_list_for_each(item, foo_list, link) { Do_something_with_item(item); } .fi .PP .SH "Field Documentation" .PP .SS "struct \fBwl_list\fP* wl_list::next" .SS "struct \fBwl_list\fP* wl_list::prev" .SH "Author" .PP Generated automatically by Doxygen for Wayland from the source code\&.