1
00:00:00,540 --> 00:00:04,020
Now let's consume our new list data type.

2
00:00:04,020 --> 00:00:07,170
So we will initialize a new list and give some items to it.

3
00:00:07,170 --> 00:00:12,300
So we will then insert several items again and find out how it works.

4
00:00:12,780 --> 00:00:19,560
So and then we will remove an item that we previously searched for and then search for the item again

5
00:00:19,560 --> 00:00:21,810
to ensure that it has gone.

6
00:00:22,200 --> 00:00:29,190
So let's actually create our code now inside the main main.cpp file.

7
00:00:29,550 --> 00:00:34,590
Let's actually as you can see, our main file is empty and we will write it on the Main.cpp file.

8
00:00:34,590 --> 00:00:37,770
And we firstly need to initialize a list.

9
00:00:39,280 --> 00:00:41,620
So we will first initialize a list.

10
00:00:42,960 --> 00:00:44,850
Which is going to be list.

11
00:00:44,850 --> 00:00:45,240
List.

12
00:00:45,360 --> 00:00:48,420
Here's list and list.

13
00:00:49,480 --> 00:00:49,720
Here.

14
00:00:49,720 --> 00:00:55,210
We will add several items to the list, which is actually list dot insert.

15
00:00:55,950 --> 00:01:01,170
Uh, the list at insert from on index zero 21.

16
00:01:01,650 --> 00:01:03,870
List at insert.

17
00:01:05,520 --> 00:01:08,550
Index 1 to 99.

18
00:01:12,090 --> 00:01:14,700
Index to 87.

19
00:01:17,550 --> 00:01:21,450
Let's insert some items like let's insert actually five items.

20
00:01:21,750 --> 00:01:22,540
Let's start.

21
00:01:22,590 --> 00:01:25,050
Insert index three.

22
00:01:25,720 --> 00:01:27,100
6 to 9.

23
00:01:28,560 --> 00:01:31,650
List that insert index for.

24
00:01:32,530 --> 00:01:33,400
50.

25
00:01:35,560 --> 00:01:39,490
55 or let's actually do it more different.

26
00:01:39,580 --> 00:01:42,610
Decimal the 30.

27
00:01:43,710 --> 00:01:44,760
35.

28
00:01:44,910 --> 00:01:45,600
Yeah.

29
00:01:46,230 --> 00:01:47,580
Here, this.

30
00:01:47,580 --> 00:01:53,430
We added several items to the list and we also indexed value index value index value and index value

31
00:01:53,460 --> 00:01:53,910
here.

32
00:01:53,910 --> 00:01:56,670
So now we will print the current list.

33
00:01:57,840 --> 00:02:04,830
So in order to print that, we will use a C out list here.

34
00:02:05,830 --> 00:02:11,300
List elements here and after that inline.

35
00:02:11,630 --> 00:02:16,590
Now we will use the for loop to print this list.

36
00:02:16,610 --> 00:02:18,620
For E here zero.

37
00:02:18,650 --> 00:02:22,280
While E is less than list dot count.

38
00:02:22,280 --> 00:02:28,850
So as you know, we have a count which will return our list count here.

39
00:02:29,510 --> 00:02:30,380
So.

40
00:02:31,850 --> 00:02:36,170
Here list.com and then.

41
00:02:37,590 --> 00:02:41,760
Um, e plus plus increment E by one plus, plus e here.

42
00:02:42,390 --> 00:02:48,360
After that, we will use the C out list to get our index E here.

43
00:02:48,360 --> 00:02:57,330
So as you know, the index e will go through zero one, two, three, four, and after the five, it

44
00:02:57,330 --> 00:02:59,400
will be broken here.

45
00:02:59,790 --> 00:03:03,600
So that's why the we are getting every time different items.

46
00:03:03,600 --> 00:03:09,030
So that's why iterating so but I think you learned that in previous lectures so I will not mention it

47
00:03:09,030 --> 00:03:09,570
again.

48
00:03:10,320 --> 00:03:11,730
So here.

49
00:03:12,980 --> 00:03:20,500
Now we printed our list items using for loop, and after that we will see out.

50
00:03:20,510 --> 00:03:22,270
Actually, yeah we will.

51
00:03:22,280 --> 00:03:23,910
After that we will use the end.

52
00:03:23,930 --> 00:03:24,800
And here.

53
00:03:24,800 --> 00:03:25,430
End line.

54
00:03:26,710 --> 00:03:31,060
And line and and line two and line here.

55
00:03:31,780 --> 00:03:35,710
Now we will insert several items in the middle of the list here.

56
00:03:37,170 --> 00:03:42,150
List dot insert 225.

57
00:03:42,390 --> 00:03:49,260
For example in second and let's start insert list dot insert two.

58
00:03:50,680 --> 00:03:53,170
Uh, 61 here.

59
00:03:53,620 --> 00:03:55,540
Now we will print the list again.

60
00:03:56,200 --> 00:03:59,250
Uh, so in order to print it, we will copy this.

61
00:03:59,260 --> 00:04:01,300
Actually, we can do it here.

62
00:04:01,450 --> 00:04:04,380
C out new list elements.

63
00:04:04,390 --> 00:04:08,960
List elements here and line.

64
00:04:08,980 --> 00:04:11,290
And after that we will use the for loop.

65
00:04:12,220 --> 00:04:12,910
For loop.

66
00:04:12,910 --> 00:04:24,100
The integer is here zero while e is less than uh, list dot count and then it will iterate increment

67
00:04:24,100 --> 00:04:24,910
by one.

68
00:04:25,870 --> 00:04:29,680
After that we will see out the list.

69
00:04:29,680 --> 00:04:35,890
Dot, get here E and after that.

70
00:04:37,960 --> 00:04:38,440
Inline.

71
00:04:38,440 --> 00:04:38,910
Yeah.

72
00:04:40,100 --> 00:04:40,880
End line.

73
00:04:42,000 --> 00:04:45,330
And the section make it to lines and lines here.

74
00:04:47,310 --> 00:04:50,400
So now let's actually search here.

75
00:04:51,150 --> 00:04:57,300
Now we use the inserts and now let's actually use the search here.

76
00:04:57,300 --> 00:04:59,610
So we also use the get insert.

77
00:04:59,640 --> 00:05:01,050
Now we're going to use the search.

78
00:05:03,310 --> 00:05:05,730
Here now we're going to search.

79
00:05:05,740 --> 00:05:08,050
So, for example, let's actually search the value.

80
00:05:08,080 --> 00:05:24,940
61 So actually add the comments, search the value 69 and here see out search element 70 or 61 and after

81
00:05:24,940 --> 00:05:26,560
that inline again.

82
00:05:27,010 --> 00:05:28,060
So we will.

83
00:05:28,890 --> 00:05:31,030
Create a new integer called result.

84
00:05:31,050 --> 00:05:35,100
Integer result list dot search.

85
00:05:36,420 --> 00:05:37,320
61.

86
00:05:37,830 --> 00:05:41,050
And if the result result.

87
00:05:41,070 --> 00:05:44,640
Result is my equals to minus one.

88
00:05:44,640 --> 00:05:52,680
So as you remember the search item here, the search item here will return.

89
00:05:53,490 --> 00:05:55,500
The search item will return.

90
00:05:58,160 --> 00:06:07,400
Minus one, if the list is not found here, will return minus one if the list is not found.

91
00:06:08,000 --> 00:06:11,540
So let's delete this again and come here.

92
00:06:12,850 --> 00:06:13,630
Here.

93
00:06:13,780 --> 00:06:17,260
So then it will see out.

94
00:06:17,260 --> 00:06:24,250
The 61 is not found if if the result is equal to minus one.

95
00:06:24,400 --> 00:06:26,800
So 61.

96
00:06:28,930 --> 00:06:30,250
Is not found.

97
00:06:31,180 --> 00:06:35,830
And after that, again, end line, end line here.

98
00:06:36,250 --> 00:06:42,970
If the else happens, then the else statement in this case, it's that it means it found our.

99
00:06:44,060 --> 00:06:44,960
Index.

100
00:06:44,960 --> 00:06:46,280
So else.

101
00:06:48,070 --> 00:06:55,300
See out, 61 is found at index and we will pass the index here.

102
00:06:55,540 --> 00:07:01,810
The index is in this case, index is result and end line.

103
00:07:02,740 --> 00:07:03,250
Here.

104
00:07:04,060 --> 00:07:07,270
So we also use the search here.

105
00:07:09,350 --> 00:07:10,940
We also use the search here.

106
00:07:10,970 --> 00:07:15,110
Now, let's actually use the remove method here.

107
00:07:15,230 --> 00:07:20,760
So now after that, we will use the remote view and do some actions with it.

108
00:07:20,780 --> 00:07:27,890
So let's actually write a remove element at index three or index two.

109
00:07:28,610 --> 00:07:34,800
And here in line after that, we will release that remove tube.

110
00:07:35,240 --> 00:07:41,000
For example, since we are telling the user that we are going to remove the index at tube.

111
00:07:41,570 --> 00:07:42,920
So now.

112
00:07:46,030 --> 00:07:50,470
We will remove use the remove method and after that.

113
00:07:53,260 --> 00:07:54,190
Actually, we do.

114
00:07:54,220 --> 00:07:55,420
Do we print anything?

115
00:07:55,420 --> 00:07:55,900
Yeah.

116
00:07:55,990 --> 00:07:58,150
Then now we don't need anything here.

117
00:07:58,150 --> 00:08:00,700
So now let's actually print the list again.

118
00:08:01,410 --> 00:08:03,210
Signs here.

119
00:08:03,720 --> 00:08:04,800
Prints the list again.

120
00:08:04,800 --> 00:08:07,110
Print the list again.

121
00:08:07,470 --> 00:08:19,680
So see out new list elements here and line after that for integer here equals zero zero.

122
00:08:19,770 --> 00:08:25,590
While e is less than list that get get count or.

123
00:08:27,580 --> 00:08:32,440
Or count here and increment a by one.

124
00:08:33,500 --> 00:08:39,320
After that, we will print the list, that list item each time.

125
00:08:41,930 --> 00:08:42,800
And line.

126
00:08:43,310 --> 00:08:44,810
And here.

127
00:08:46,920 --> 00:08:54,780
We will also search the volume value of 71 again here, 60, 61 again.

128
00:08:54,780 --> 00:09:05,400
So search the value 61 again to check if it is removed here.

129
00:09:06,350 --> 00:09:08,270
Now see out.

130
00:09:09,070 --> 00:09:16,420
Search the element 71 or 61 again and after the line.

131
00:09:18,960 --> 00:09:22,470
Now the result is going to be less that search.

132
00:09:23,330 --> 00:09:24,170
71.

133
00:09:24,350 --> 00:09:30,650
So as again, if our the result if our result is equal to minus one.

134
00:09:30,650 --> 00:09:40,850
So this means we couldn't find anything and we will print the user that 71 is not found or 71.

135
00:09:40,940 --> 00:09:41,720
61.

136
00:09:42,320 --> 00:09:43,610
Oops, not 71.

137
00:09:43,790 --> 00:09:44,390
Sorry.

138
00:09:44,390 --> 00:09:45,540
So 70.

139
00:09:45,740 --> 00:09:46,550
61.

140
00:09:47,670 --> 00:09:49,230
Is not fond.

141
00:09:50,440 --> 00:09:52,360
And after that line here.

142
00:09:52,540 --> 00:09:55,870
So else if the else happens.

143
00:09:57,590 --> 00:09:59,120
If else happens.

144
00:09:59,420 --> 00:09:59,930
But why?

145
00:09:59,930 --> 00:10:01,370
It's showing.

146
00:10:04,250 --> 00:10:06,620
Result list search here.

147
00:10:06,620 --> 00:10:08,330
So if else happens.

148
00:10:09,720 --> 00:10:16,890
Then print the user that 61 is found at index.

149
00:10:17,820 --> 00:10:19,960
And this is our result.

150
00:10:19,980 --> 00:10:22,530
We will print the result integer here and then line here.

151
00:10:22,530 --> 00:10:26,380
And after that we are done with our code here.

152
00:10:26,400 --> 00:10:34,380
So fortunately, our list datatype works well and we can apply all the operation that list should have.

153
00:10:34,530 --> 00:10:38,400
So here let's actually open clear CLS.

154
00:10:38,550 --> 00:10:41,820
So if you build and run this application here.

155
00:10:42,630 --> 00:10:45,820
So it was main.cpp and yeah.

156
00:10:45,870 --> 00:10:48,000
G plus plus color.

157
00:10:48,780 --> 00:10:50,100
G plus plus.

158
00:10:51,520 --> 00:10:52,470
Cplusplus.

159
00:10:52,500 --> 00:10:53,760
Main.cpp.

160
00:10:56,520 --> 00:10:58,140
And as you can see, we get an error.

161
00:10:59,160 --> 00:11:03,180
Let's actually compile it and on the machine and see what happens.

162
00:11:04,210 --> 00:11:05,860
So 78.

163
00:11:06,100 --> 00:11:08,230
Yeah, we have undefined reference.

164
00:11:08,230 --> 00:11:11,370
So we didn't actually define this count yet.

165
00:11:11,380 --> 00:11:14,830
So we also we will also need to define count.

166
00:11:14,830 --> 00:11:15,640
So.

167
00:11:16,920 --> 00:11:17,730
Here.

168
00:11:18,500 --> 00:11:21,680
And that's the integer discount returns in just an integer.

169
00:11:22,940 --> 00:11:24,110
So here.

170
00:11:24,950 --> 00:11:26,270
Uh, integers.

171
00:11:26,580 --> 00:11:29,360
List count.

172
00:11:30,230 --> 00:11:32,180
So the count is going to be.

173
00:11:36,070 --> 00:11:36,610
Here.

174
00:11:36,610 --> 00:11:38,680
Now we're going to develop our count.

175
00:11:40,240 --> 00:11:41,380
Count method here.

176
00:11:41,380 --> 00:11:43,870
So the count method returns integer.

177
00:11:45,780 --> 00:11:51,540
This means that we're going to use return just and return our.

178
00:11:52,880 --> 00:11:53,840
Our first lecture.

179
00:11:53,840 --> 00:11:54,890
Create the count.

180
00:11:55,490 --> 00:11:57,770
My array count.

181
00:11:57,800 --> 00:12:00,200
Or do we have the count here?

182
00:12:00,440 --> 00:12:01,790
Count by default?

183
00:12:01,820 --> 00:12:04,100
No, we don't have anything like that.

184
00:12:04,100 --> 00:12:04,550
So.

185
00:12:04,550 --> 00:12:05,210
Yes.

186
00:12:05,780 --> 00:12:06,700
Integer.

187
00:12:07,460 --> 00:12:12,410
My count here equals the size of.

188
00:12:12,830 --> 00:12:21,050
Size of our array, which is going to be the size of our array is going to be like the.

189
00:12:25,260 --> 00:12:38,790
My items, size of my items, my items and we will use multiply it by divided by size of our my items.

190
00:12:43,600 --> 00:12:43,960
Here.

191
00:12:43,960 --> 00:12:46,660
We also have the my count here.

192
00:12:47,110 --> 00:12:47,800
It's actually.

193
00:12:47,800 --> 00:12:48,520
Yes.

194
00:12:50,020 --> 00:12:51,280
My count.

195
00:12:51,820 --> 00:12:53,560
So we also have the Mekons.

196
00:12:53,560 --> 00:12:54,250
So.

197
00:12:59,760 --> 00:12:59,960
Um.

198
00:13:00,090 --> 00:13:01,980
Uh, size of items.

199
00:13:03,120 --> 00:13:03,630
And.

200
00:13:08,080 --> 00:13:10,810
Size of my items and.

201
00:13:10,810 --> 00:13:11,230
Yeah.

202
00:13:12,360 --> 00:13:17,100
We will use the index and zero here.

203
00:13:17,220 --> 00:13:18,090
So that's it.

204
00:13:18,510 --> 00:13:19,950
Let's actually run our program.

205
00:13:19,950 --> 00:13:21,510
I think it will give it an error.

206
00:13:21,510 --> 00:13:24,270
Yes, it will give a no return statement, the function.

207
00:13:24,270 --> 00:13:32,490
So, yes, we need to return statement here, return my count, and let's run the program again.

208
00:13:32,490 --> 00:13:34,530
And as you can see here, we get an error.

209
00:13:35,880 --> 00:13:37,560
The thing is.

210
00:13:42,980 --> 00:13:45,500
Undefined reference to the list list here.

211
00:14:10,520 --> 00:14:18,350
And as you can see here, the list that Conte will return as the conte of our race.
