static int del() { B6_LIST_DEFINE(list); struct b6_dref dref[3]; int i; for (i = 0; i < b6_card_of(dref); i += 1) if (&dref[i] != b6_list_add_last(&list, &dref[i])) return 0; for (i = 0; i < b6_card_of(dref); i += 1) { if (&dref[b6_card_of(dref) - 1] != b6_list_last(&list)) return 0; if (&dref[i] != b6_list_del(&dref[i])) return 0; } if (b6_list_head(&list) != b6_list_last(&list)) return 0; if (!b6_list_empty(&list)) return 0; return 1; }
static int walk() { B6_LIST_DEFINE(list); struct b6_dref dref[16]; struct b6_dref *iter; int i; for (i = 0; i < b6_card_of(dref); i += 1) if (&dref[i] != b6_list_add_last(&list, &dref[i])) return 0; for (i = 0, iter = b6_list_first(&list); iter != b6_list_tail(&list); iter = b6_list_walk(iter, B6_NEXT), i += 1) if (iter != &dref[i]) return 0; if (i != b6_card_of(dref)) return 0; for (i = 0, iter = b6_list_last(&list); iter != b6_list_head(&list); iter = b6_list_walk(iter, B6_PREV), i += 1) if (iter != &dref[b6_card_of(dref) - 1 - i]) return 0; if (i != b6_card_of(dref)) return 0; return 1; }
static int add_last() { B6_LIST_DEFINE(list); struct b6_dref dref[2]; int i; for (i = 0; i < b6_card_of(dref); i += 1) { if (&dref[i] != b6_list_add_last(&list, &dref[i])) return 0; if (&dref[i] != b6_list_last(&list)) return 0; if (b6_list_empty(&list)) return 0; } return 1; }
void previous_menu_entry(struct menu *self) { walk_menu_entry(self, B6_PREV, b6_list_head(&self->entries), b6_list_last(&self->entries)); }
static int last_is_head_when_empty() { B6_LIST_DEFINE(list); return b6_list_last(&list) == b6_list_head(&list); }