/*------------------------------------------------------------------*/ /* testlist.c (Version 3: Internal Selected Node) */ /*------------------------------------------------------------------*/ #include "list.h" #include #include #include int main(int argc, char *argv[]) { List_T oList; oList = List_new(); List_addFirst(oList, "Ruth"); List_addFirst(oList, "Gehrig"); List_addLast(oList, "Mantle"); List_addLast(oList, "Jeter"); List_selectFirst(oList); while (List_selectionValid(oList)) { printf("%s\n", (char*)List_selectedItem(oList)); List_selectNext(oList); } List_selectLast(oList); while (List_selectionValid(oList)) { printf("%s\n", (char*)List_selectedItem(oList)); List_selectPrev(oList); } List_free(oList); return 0; } /* Output: Gehrig Ruth Mantle Jeter Jeter Mantle Ruth Gehrig */