diff --git a/d8/dfa/median__search2_8cpp.html b/d8/dfa/median__search2_8cpp.html index 8c1a9cbd9..674b78766 100644 --- a/d8/dfa/median__search2_8cpp.html +++ b/d8/dfa/median__search2_8cpp.html @@ -141,6 +141,8 @@ Namespaces Functions ListNodesearch::median_search2::middleNode (ListNode *head)   +void search::median_search2::deleteAll (const ListNode *const head) +  static void test ()  Self-test implementations.
  @@ -157,6 +159,29 @@ hare"](
Author
Benjamin Weiss
See also
median_search.cpp

Function Documentation

+ +

◆ deleteAll()

+ +
+
+ + + + + + + +
void search::median_search2::deleteAll (const ListNode *const head)
+
+
77 {
+
78 if (head) {
+
79 deleteAll(head->next);
+
80 delete head;
+
81 }
+
82}
+
+
+

◆ main()

@@ -174,11 +199,11 @@ hare"](
Returns
0 on exit
-
136 {
-
137 test(); // run self-test implementations
-
138 return 0;
-
139}
-
static void test()
Self-test implementations.
Definition median_search2.cpp:83
+
139 {
+
140 test(); // run self-test implementations
+
141 return 0;
+
142}
+
static void test()
Self-test implementations.
Definition median_search2.cpp:90
Here is the call graph for this function:
@@ -260,54 +285,50 @@ Here is the call graph for this function:

Self-test implementations.

Returns
void
-
83 {
-
84 auto* head1 = new ListNode;
-
85 head1->val = 1;
-
86
-
87 ListNode* temp = head1;
-
88 for (int i = 2; i < 6; ++i) {
-
89 // Allocate next
-
90 auto* temp1 = new ListNode;
-
91 temp1->val = i;
-
92
-
93 // Advance
-
94 temp->next = temp1;
-
95 temp = temp1;
-
96 }
-
97 temp->next = nullptr;
-
98
- -
100 assert(3 == median->val); // 3 is the value of the median node.
-
101 std::cout << "test case:1 passed\n";
-
102
-
103 // Test case # 2
-
104 auto* head2 = new ListNode;
-
105 head2->val = 1;
-
106
-
107 ListNode* temp2 = head2;
-
108 for (int i = 2; i < 7; ++i) {
-
109 // Allocate next
-
110 auto* temp3 = new ListNode;
-
111 temp3->val = i;
-
112
-
113 // Advance
-
114 temp2->next = temp3;
-
115 temp2 = temp3;
-
116 }
-
117 temp2->next = nullptr;
-
118
- -
120 assert(4 == median1->val); // 4 is the value of the median node.
-
121 std::cout << "test case:2 passed\n";
-
122
-
123 delete head1;
-
124 delete temp;
-
125
-
126 delete head2;
-
127 delete temp2;
-
128
-
129 std::cout << "--All tests passed--\n";
-
130}
+
90 {
+
91 auto* head1 = new ListNode;
+
92 head1->val = 1;
+
93
+
94 ListNode* temp = head1;
+
95 for (int i = 2; i < 6; ++i) {
+
96 // Allocate next
+
97 auto* temp1 = new ListNode;
+
98 temp1->val = i;
+
99
+
100 // Advance
+
101 temp->next = temp1;
+
102 temp = temp1;
+
103 }
+
104 temp->next = nullptr;
+
105
+ +
107 assert(3 == median->val); // 3 is the value of the median node.
+
108 search::median_search2::deleteAll(head1);
+
109 std::cout << "test case:1 passed\n";
+
110
+
111 // Test case # 2
+
112 auto* head2 = new ListNode;
+
113 head2->val = 1;
+
114
+
115 ListNode* temp2 = head2;
+
116 for (int i = 2; i < 7; ++i) {
+
117 // Allocate next
+
118 auto* temp3 = new ListNode;
+
119 temp3->val = i;
+
120
+
121 // Advance
+
122 temp2->next = temp3;
+
123 temp2 = temp3;
+
124 }
+
125 temp2->next = nullptr;
+
126
+ +
128 assert(4 == median1->val); // 4 is the value of the median node.
+
129 search::median_search2::deleteAll(head2);
+
130 std::cout << "test case:2 passed\n";
+
131
+
132 std::cout << "--All tests passed--\n";
+
133}
ListNode * middleNode(ListNode *head)
Definition median_search2.cpp:59
int val
the value stored in the node
Definition median_search2.cpp:32