Skip to content

Commit 72a4eeb

Browse files
committed
explore more method use to manipulate the list
1 parent 039066d commit 72a4eeb

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

List.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ int main(){
1717
list1.push_back(5);
1818
list1.push_back(7);
1919
list1.push_back(57);
20+
list1.push_back(4);
2021

2122
//! Way 1st to print the list
2223
/*
@@ -38,26 +39,41 @@ int main(){
3839
*/
3940

4041
//! Way 3rd to print the list
41-
display(list1);
42+
// display(list1);
4243

4344
//? Delete an element from the list at the end
44-
list1.pop_back();
45+
// list1.pop_back();
4546
//? Delete an element from the list at the front
46-
list1.pop_front();
47+
// list1.pop_front();
48+
//? Delete an element from middle in the list
49+
// list1.remove(4);
50+
51+
52+
//* Sorting the list
53+
// list1.sort();
4754
display(list1);
4855

4956
//* Create another list
5057
list<int> list2(3); // Empty list of size 3
5158
list<int>::iterator itr;
5259
itr = list2.begin();
53-
*itr = 7.5;
60+
*itr = 4.5;
5461
itr++;
5562
*itr = 5.7;
5663
itr++;
5764
*itr = 7.5;
5865
itr++;
59-
// display(list2);
66+
display(list2);
6067

68+
69+
//? Merging two or more lists
70+
// list1.merge(list2);
71+
// cout << "After merging the list: "<<endl ;
72+
73+
74+
//? Reversing the list
75+
// list1.reverse();
76+
display(list1);
6177
return 0;
6278
}
6379

List.exe

-1.24 KB
Binary file not shown.

0 commit comments

Comments
 (0)