410 likes | 423 Views
List class. _class Cell { void *object; Cell *next; public: ... } _class List { Cell *head; public: ... }. NULL. .head. Insert objects into a List. List class. NULL. head. .object. List class. NULL. .cell = new Cell();. head. .object. List class.
E N D
List class _class Cell { void *object; Cell *next; public: ... } _class List { Cell *head; public: ... } NULL .head
List class NULL head .object
List class NULL .cell = new Cell(); head .object
List class cell->next = NULL; cell->object = object; NULL .cell head NULL .object
List class head = cell; .cell head NULL .object
List class head NULL
List class head NULL cell = new Cell(); object
List class cell->next = NULL; cell->object = object; head NULL cell NULL object
List class head->next = cell; head cell NULL object
List class head->next = cell; head NULL
List class - find an object and remove it head if (find(head->object, object)) {... NULL
List class - find an object and remove it head .ptr if (find(ptr->next->object, object)) { NULL
List class - find an object and remove it head .ptr ptr = ptr->next; NULL
List class - find an object and remove it head .ptr if (find(ptr->next->object, object)) { NULL
List class - find an object and remove it head .ptr void *object = ptr->next->object NULL _object
List class - find an object and remove it head .ptr tmp Cell *tmp = ptr->next; NULL _object
List class - find an object and remove it head .ptr tmp ptr->next = ptr->next->next; NULL _object
List class - find an object and remove it head .ptr tmp delete tmp; NULL _object
List class - find an object and remove it head return object; NULL _object
Doubly Linked Lists .tail head NULL
Doubly Linked Lists .tail head NULL NULL
Doubly Linked Lists head .tail NULL NULL
Doubly Linked Lists head NULL NULL tail
Circularly linked list .tail
Queue: remove from front _object .tail void *object = tail->next->object;
Queue: remove from front Temp tmp _object .tail tmp = tail->next;
Queue: remove from front Temp tmp _object .tail _tail->next = tail->next->next;
Queue: remove from front Temp tmp _object .tail delete tmp;
Queue: remove from front Temp _object .tail _return object;
Queue: remove from front Temp .tail _
Queue: insert at rear Temp .tail _
Queue: insert at rear _cell Temp NULL .tail _cell = new Cell(object);
Queue: insert at rear _cell Temp .tail _cell->next = tail->next;
Queue: insert at rear _cell Temp .tail _tail->next = cell;
Queue: insert at rear _cell Temp .tail _tail = tail->next;