Skip to content

Commit ad53d51

Browse files
committed
adding more examples for new functions
1 parent 5008277 commit ad53d51

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

example.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,45 @@ int main(int argc, char** argv) {
1818
// Print all nodes
1919
list->print();
2020

21+
// Print the size of the list
22+
cout << "Size: " << list->getSize() << endl;
23+
24+
// Check has a node with a specific data in the list or not
25+
cout << "Has 110: " << list->has(110) << endl;
26+
cout << "Has 111: " << list->has(111) << endl;
27+
28+
// Get the node by searching with data
29+
Node* node = list->getNode(110);
30+
if(node != NULL) {
31+
cout << "Node data: " << node->data << endl;
32+
} else {
33+
cout << "Node not found" << endl;
34+
}
35+
36+
// Get the node by searching with index
37+
node = list->getNodeByIndex(0);
38+
if(node != NULL) {
39+
cout << "Node data: " << node->data << endl;
40+
} else {
41+
cout << "Node not found" << endl;
42+
}
43+
44+
// Get the node by searching with index
45+
node = list->getNodeByIndex(60);
46+
if(node != NULL) {
47+
cout << "Node data: " << node->data << endl;
48+
} else {
49+
cout << "Node not found" << endl;
50+
}
51+
2152
// Delete all nodes
2253
list->deleteAll();
2354

2455
// Print all nodes
2556
list->print();
2657

58+
// Print the size of the list
59+
cout << "Size: " << list->getSize() << endl;
60+
2761
return 0;
2862
}

0 commit comments

Comments
 (0)