Download presentation
Presentation is loading. Please wait.
1
List class.head NULL _class Cell { void *object; Cell *next; public:... } _class List { Cell *head; public:... }
2
Insert objects into a List
3
List class.object NULL head
4
List class.object.cell = new Cell(); NULL head
5
List class NULL.object.cell cell->next = NULL; cell->object = object; NULL head
6
List class.object.cell head = cell; NULL head
7
List class head NULL
8
List class NULL cell = new Cell(); object head
9
List class NULL cell head cell->next = NULL; cell->object = object; object NULL
10
List class head->next = cell; NULL cell object head
11
List class head->next = cell; NULL head
12
Find and remove an object
13
List class - find an object and remove it head NULL
14
List class - find an object and remove it NULL if (find(head->object, object)) {... head
15
List class - find an object and remove it NULL if (find(ptr->next->object, object)) {.ptr head
16
List class - find an object and remove it NULL ptr = ptr->next;.ptr head
17
List class - find an object and remove it NULL if (find(ptr->next->object, object)) {.ptr head
18
List class - find an object and remove it NULL void *object = ptr->next->object _object head.ptr
19
List class - find an object and remove it NULL Cell *tmp = ptr->next;.ptr _object tmp head
20
List class - find an object and remove it NULL ptr->next = ptr->next->next; _object tmp head.ptr
21
List class - find an object and remove it NULL delete tmp; _object tmp head.ptr
22
List class - find an object and remove it NULL return object; _object head
23
Doubly Linked Lists
24
head NULL.tail
25
Doubly Linked Lists head NULL.tail
26
Doubly Linked Lists head NULL.tail NULL
27
Doubly Linked Lists head NULL tail NULL
28
A Queue
29
.tail Circularly linked list
30
.tail Queue: insert item at rear, remove at front
31
.tail Queue: remove from front void *object = tail->next->object; _object
32
.tail Queue: remove from front tmp = tail->next; _object TempTemp tmp
33
.tail Queue: remove from front _tail->next = tail->next->next; _object TempTemp tmp
34
.tail Queue: remove from front delete tmp; _object TempTemp tmp
35
.tail Queue: remove from front _return object; _object TempTemp
36
.tail Queue: remove from front _ TempTemp
37
.tail Queue: insert at rear _ TempTemp
38
.tail Queue: insert at rear _cell = new Cell(object); TempTemp _cell NULL
39
.tail Queue: insert at rear _cell->next = tail->next; TempTemp _cell
40
.tail Queue: insert at rear _tail->next = cell; TempTemp _cell
41
.tail Queue: insert at rear _tail = tail->next; TempTemp _cell
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.