void DblLnkLst_LinkLast(DblLnkLst_Links *head, // IN DblLnkLst_Links *l) // IN { ASSERT(head); ASSERT(l); DblLnkLst_Link(head, l); }
void DblLnkLst_LinkFirst(DblLnkLst_Links *head, // IN DblLnkLst_Links *l) // IN { ASSERT(head); ASSERT(l); DblLnkLst_Link(head->next, l); }
/* Test code entry point */ int main(int argc, // IN char **argv) // IN { member *c1; member *c2; member *c3; member *c4; DblLnkLst_Links h; member *a1; member *a2; member *a3; printf("Circular list: there is no origin\n"); /* Create the 1st member */ c1 = make_member(1); /* Special case: there is no list to merge with, initially */ /* Add the 2nd member _after_ the 1st one */ c2 = make_member(2); DblLnkLst_Link(&c1->l, &c2->l); /* Add the 3rd member _after_ the 2nd one */ c3 = make_member(3); DblLnkLst_Link(&c1->l, &c3->l); /* Add the 4th member _before_ the 3rd one */ c4 = make_member(4); DblLnkLst_Link(&c3->l, &c4->l); printf("See it from this member...\n"); dump_circular(c1); printf("...Or from this one\n"); dump_circular(c4); printf("\n"); printf("Anchored (linear) list: it has a beginning and an end\n"); /* Create the 'head' of the list */ DblLnkLst_Init(&h); /* Add the 1st member at the _end_ */ a1 = make_member(5); DblLnkLst_LinkLast(&h, &a1->l); /* Add the 2nd member at the _beginning_ */ a2 = make_member(6); DblLnkLst_LinkFirst(&h, &a2->l); /* Add the 3rd member _before_ the 1st one */ a3 = make_member(7); DblLnkLst_Link(&a1->l, &a3->l); dump_anchored(&h); printf("\n"); printf("Merge both lists: the result is an anchored list\n"); DblLnkLst_Link(&h, &c4->l); dump_anchored(&h); printf("\n"); printf("Remove a member\n"); DblLnkLst_Unlink1(&c3->l); dump_anchored(&h); printf("\n"); printf("Split the result in two lists: an anchored one and a circular " "one\n"); DblLnkLst_Unlink(&h, &a1->l); dump_anchored(&h); dump_circular(a1); return 0; }