Definition at line 11 of file doubly_linked_list.cpp.
◆ double_linked_list()
double_linked_list::double_linked_list |
( |
| ) |
|
|
inline |
◆ insert()
void double_linked_list::insert |
( |
int | x | ) |
|
Definition at line 21 of file doubly_linked_list.cpp.
21 {
23 if (start != NULL) {
24 while (t->next != NULL) {
25 t = t->next;
26 }
28 t->next = n;
29 n->prev = t;
30 n->val = x;
31 n->next = NULL;
32 } else {
34 n->val = x;
35 n->prev = NULL;
36 n->next = NULL;
37 start = n;
38 }
39}
struct node { int data; int height; struct node *left; struct node *right;} node
for std::queue
◆ remove()
void double_linked_list::remove |
( |
int | x | ) |
|
Definition at line 41 of file doubly_linked_list.cpp.
41 {
43 while (t != NULL && t->val != x) {
44 t = t->next;
45 }
46 if (t == NULL) {
47 return;
48 }
49 if (t->prev == NULL) {
50 if (t->next == NULL) {
51 start = NULL;
52 } else {
53 start = t->next;
54 start->prev = NULL;
55 }
56 } else if (t->next == NULL) {
57 t->prev->next = NULL;
58 } else {
59 t->prev->next = t->next;
60 t->next->prev = t->prev;
61 }
62 delete t;
63}
◆ reverseShow()
void double_linked_list::reverseShow |
( |
| ) |
|
Definition at line 89 of file doubly_linked_list.cpp.
89 {
91 while (t != NULL && t->next != NULL) {
92 t = t->next;
93 }
94 while (t != NULL) {
95 std::cout << t->val << "\t";
96 t = t->prev;
97 }
98}
◆ search()
void double_linked_list::search |
( |
int | x | ) |
|
Definition at line 65 of file doubly_linked_list.cpp.
65 {
67 int found = 0;
68 while (t != NULL) {
69 if (t->val == x) {
70 std::cout << "\nFound";
71 found = 1;
72 break;
73 }
74 t = t->next;
75 }
76 if (found == 0) {
77 std::cout << "\nNot Found";
78 }
79}
◆ show()
void double_linked_list::show |
( |
| ) |
|
Definition at line 81 of file doubly_linked_list.cpp.
81 {
83 while (t != NULL) {
84 std::cout << t->val << "\t";
85 t = t->next;
86 }
87}
The documentation for this class was generated from the following file: