WEBVTT

00:00.540 --> 00:04.020
Now let's consume our new list data type.

00:04.020 --> 00:07.170
So we will initialize a new list and give some items to it.

00:07.170 --> 00:12.300
So we will then insert several items again and find out how it works.

00:12.780 --> 00:19.560
So and then we will remove an item that we previously searched for and then search for the item again

00:19.560 --> 00:21.810
to ensure that it has gone.

00:22.200 --> 00:29.190
So let's actually create our code now inside the main main.cpp file.

00:29.550 --> 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.

00:34.590 --> 00:37.770
And we firstly need to initialize a list.

00:39.280 --> 00:41.620
So we will first initialize a list.

00:42.960 --> 00:44.850
Which is going to be list.

00:44.850 --> 00:45.240
List.

00:45.360 --> 00:48.420
Here's list and list.

00:49.480 --> 00:49.720
Here.

00:49.720 --> 00:55.210
We will add several items to the list, which is actually list dot insert.

00:55.950 --> 01:01.170
Uh, the list at insert from on index zero 21.

01:01.650 --> 01:03.870
List at insert.

01:05.520 --> 01:08.550
Index 1 to 99.

01:12.090 --> 01:14.700
Index to 87.

01:17.550 --> 01:21.450
Let's insert some items like let's insert actually five items.

01:21.750 --> 01:22.540
Let's start.

01:22.590 --> 01:25.050
Insert index three.

01:25.720 --> 01:27.100
6 to 9.

01:28.560 --> 01:31.650
List that insert index for.

01:32.530 --> 01:33.400
50.

01:35.560 --> 01:39.490
55 or let's actually do it more different.

01:39.580 --> 01:42.610
Decimal the 30.

01:43.710 --> 01:44.760
35.

01:44.910 --> 01:45.600
Yeah.

01:46.230 --> 01:47.580
Here, this.

01:47.580 --> 01:53.430
We added several items to the list and we also indexed value index value index value and index value

01:53.460 --> 01:53.910
here.

01:53.910 --> 01:56.670
So now we will print the current list.

01:57.840 --> 02:04.830
So in order to print that, we will use a C out list here.

02:05.830 --> 02:11.300
List elements here and after that inline.

02:11.630 --> 02:16.590
Now we will use the for loop to print this list.

02:16.610 --> 02:18.620
For E here zero.

02:18.650 --> 02:22.280
While E is less than list dot count.

02:22.280 --> 02:28.850
So as you know, we have a count which will return our list count here.

02:29.510 --> 02:30.380
So.

02:31.850 --> 02:36.170
Here list.com and then.

02:37.590 --> 02:41.760
Um, e plus plus increment E by one plus, plus e here.

02:42.390 --> 02:48.360
After that, we will use the C out list to get our index E here.

02:48.360 --> 02:57.330
So as you know, the index e will go through zero one, two, three, four, and after the five, it

02:57.330 --> 02:59.400
will be broken here.

02:59.790 --> 03:03.600
So that's why the we are getting every time different items.

03:03.600 --> 03:09.030
So that's why iterating so but I think you learned that in previous lectures so I will not mention it

03:09.030 --> 03:09.570
again.

03:10.320 --> 03:11.730
So here.

03:12.980 --> 03:20.500
Now we printed our list items using for loop, and after that we will see out.

03:20.510 --> 03:22.270
Actually, yeah we will.

03:22.280 --> 03:23.910
After that we will use the end.

03:23.930 --> 03:24.800
And here.

03:24.800 --> 03:25.430
End line.

03:26.710 --> 03:31.060
And line and and line two and line here.

03:31.780 --> 03:35.710
Now we will insert several items in the middle of the list here.

03:37.170 --> 03:42.150
List dot insert 225.

03:42.390 --> 03:49.260
For example in second and let's start insert list dot insert two.

03:50.680 --> 03:53.170
Uh, 61 here.

03:53.620 --> 03:55.540
Now we will print the list again.

03:56.200 --> 03:59.250
Uh, so in order to print it, we will copy this.

03:59.260 --> 04:01.300
Actually, we can do it here.

04:01.450 --> 04:04.380
C out new list elements.

04:04.390 --> 04:08.960
List elements here and line.

04:08.980 --> 04:11.290
And after that we will use the for loop.

04:12.220 --> 04:12.910
For loop.

04:12.910 --> 04:24.100
The integer is here zero while e is less than uh, list dot count and then it will iterate increment

04:24.100 --> 04:24.910
by one.

04:25.870 --> 04:29.680
After that we will see out the list.

04:29.680 --> 04:35.890
Dot, get here E and after that.

04:37.960 --> 04:38.440
Inline.

04:38.440 --> 04:38.910
Yeah.

04:40.100 --> 04:40.880
End line.

04:42.000 --> 04:45.330
And the section make it to lines and lines here.

04:47.310 --> 04:50.400
So now let's actually search here.

04:51.150 --> 04:57.300
Now we use the inserts and now let's actually use the search here.

04:57.300 --> 04:59.610
So we also use the get insert.

04:59.640 --> 05:01.050
Now we're going to use the search.

05:03.310 --> 05:05.730
Here now we're going to search.

05:05.740 --> 05:08.050
So, for example, let's actually search the value.

05:08.080 --> 05:24.940
61 So actually add the comments, search the value 69 and here see out search element 70 or 61 and after

05:24.940 --> 05:26.560
that inline again.

05:27.010 --> 05:28.060
So we will.

05:28.890 --> 05:31.030
Create a new integer called result.

05:31.050 --> 05:35.100
Integer result list dot search.

05:36.420 --> 05:37.320
61.

05:37.830 --> 05:41.050
And if the result result.

05:41.070 --> 05:44.640
Result is my equals to minus one.

05:44.640 --> 05:52.680
So as you remember the search item here, the search item here will return.

05:53.490 --> 05:55.500
The search item will return.

05:58.160 --> 06:07.400
Minus one, if the list is not found here, will return minus one if the list is not found.

06:08.000 --> 06:11.540
So let's delete this again and come here.

06:12.850 --> 06:13.630
Here.

06:13.780 --> 06:17.260
So then it will see out.

06:17.260 --> 06:24.250
The 61 is not found if if the result is equal to minus one.

06:24.400 --> 06:26.800
So 61.

06:28.930 --> 06:30.250
Is not found.

06:31.180 --> 06:35.830
And after that, again, end line, end line here.

06:36.250 --> 06:42.970
If the else happens, then the else statement in this case, it's that it means it found our.

06:44.060 --> 06:44.960
Index.

06:44.960 --> 06:46.280
So else.

06:48.070 --> 06:55.300
See out, 61 is found at index and we will pass the index here.

06:55.540 --> 07:01.810
The index is in this case, index is result and end line.

07:02.740 --> 07:03.250
Here.

07:04.060 --> 07:07.270
So we also use the search here.

07:09.350 --> 07:10.940
We also use the search here.

07:10.970 --> 07:15.110
Now, let's actually use the remove method here.

07:15.230 --> 07:20.760
So now after that, we will use the remote view and do some actions with it.

07:20.780 --> 07:27.890
So let's actually write a remove element at index three or index two.

07:28.610 --> 07:34.800
And here in line after that, we will release that remove tube.

07:35.240 --> 07:41.000
For example, since we are telling the user that we are going to remove the index at tube.

07:41.570 --> 07:42.920
So now.

07:46.030 --> 07:50.470
We will remove use the remove method and after that.

07:53.260 --> 07:54.190
Actually, we do.

07:54.220 --> 07:55.420
Do we print anything?

07:55.420 --> 07:55.900
Yeah.

07:55.990 --> 07:58.150
Then now we don't need anything here.

07:58.150 --> 08:00.700
So now let's actually print the list again.

08:01.410 --> 08:03.210
Signs here.

08:03.720 --> 08:04.800
Prints the list again.

08:04.800 --> 08:07.110
Print the list again.

08:07.470 --> 08:19.680
So see out new list elements here and line after that for integer here equals zero zero.

08:19.770 --> 08:25.590
While e is less than list that get get count or.

08:27.580 --> 08:32.440
Or count here and increment a by one.

08:33.500 --> 08:39.320
After that, we will print the list, that list item each time.

08:41.930 --> 08:42.800
And line.

08:43.310 --> 08:44.810
And here.

08:46.920 --> 08:54.780
We will also search the volume value of 71 again here, 60, 61 again.

08:54.780 --> 09:05.400
So search the value 61 again to check if it is removed here.

09:06.350 --> 09:08.270
Now see out.

09:09.070 --> 09:16.420
Search the element 71 or 61 again and after the line.

09:18.960 --> 09:22.470
Now the result is going to be less that search.

09:23.330 --> 09:24.170
71.

09:24.350 --> 09:30.650
So as again, if our the result if our result is equal to minus one.

09:30.650 --> 09:40.850
So this means we couldn't find anything and we will print the user that 71 is not found or 71.

09:40.940 --> 09:41.720
61.

09:42.320 --> 09:43.610
Oops, not 71.

09:43.790 --> 09:44.390
Sorry.

09:44.390 --> 09:45.540
So 70.

09:45.740 --> 09:46.550
61.

09:47.670 --> 09:49.230
Is not fond.

09:50.440 --> 09:52.360
And after that line here.

09:52.540 --> 09:55.870
So else if the else happens.

09:57.590 --> 09:59.120
If else happens.

09:59.420 --> 09:59.930
But why?

09:59.930 --> 10:01.370
It's showing.

10:04.250 --> 10:06.620
Result list search here.

10:06.620 --> 10:08.330
So if else happens.

10:09.720 --> 10:16.890
Then print the user that 61 is found at index.

10:17.820 --> 10:19.960
And this is our result.

10:19.980 --> 10:22.530
We will print the result integer here and then line here.

10:22.530 --> 10:26.380
And after that we are done with our code here.

10:26.400 --> 10:34.380
So fortunately, our list datatype works well and we can apply all the operation that list should have.

10:34.530 --> 10:38.400
So here let's actually open clear CLS.

10:38.550 --> 10:41.820
So if you build and run this application here.

10:42.630 --> 10:45.820
So it was main.cpp and yeah.

10:45.870 --> 10:48.000
G plus plus color.

10:48.780 --> 10:50.100
G plus plus.

10:51.520 --> 10:52.470
Cplusplus.

10:52.500 --> 10:53.760
Main.cpp.

10:56.520 --> 10:58.140
And as you can see, we get an error.

10:59.160 --> 11:03.180
Let's actually compile it and on the machine and see what happens.

11:04.210 --> 11:05.860
So 78.

11:06.100 --> 11:08.230
Yeah, we have undefined reference.

11:08.230 --> 11:11.370
So we didn't actually define this count yet.

11:11.380 --> 11:14.830
So we also we will also need to define count.

11:14.830 --> 11:15.640
So.

11:16.920 --> 11:17.730
Here.

11:18.500 --> 11:21.680
And that's the integer discount returns in just an integer.

11:22.940 --> 11:24.110
So here.

11:24.950 --> 11:26.270
Uh, integers.

11:26.580 --> 11:29.360
List count.

11:30.230 --> 11:32.180
So the count is going to be.

11:36.070 --> 11:36.610
Here.

11:36.610 --> 11:38.680
Now we're going to develop our count.

11:40.240 --> 11:41.380
Count method here.

11:41.380 --> 11:43.870
So the count method returns integer.

11:45.780 --> 11:51.540
This means that we're going to use return just and return our.

11:52.880 --> 11:53.840
Our first lecture.

11:53.840 --> 11:54.890
Create the count.

11:55.490 --> 11:57.770
My array count.

11:57.800 --> 12:00.200
Or do we have the count here?

12:00.440 --> 12:01.790
Count by default?

12:01.820 --> 12:04.100
No, we don't have anything like that.

12:04.100 --> 12:04.550
So.

12:04.550 --> 12:05.210
Yes.

12:05.780 --> 12:06.700
Integer.

12:07.460 --> 12:12.410
My count here equals the size of.

12:12.830 --> 12:21.050
Size of our array, which is going to be the size of our array is going to be like the.

12:25.260 --> 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.

12:43.600 --> 12:43.960
Here.

12:43.960 --> 12:46.660
We also have the my count here.

12:47.110 --> 12:47.800
It's actually.

12:47.800 --> 12:48.520
Yes.

12:50.020 --> 12:51.280
My count.

12:51.820 --> 12:53.560
So we also have the Mekons.

12:53.560 --> 12:54.250
So.

12:59.760 --> 12:59.960
Um.

13:00.090 --> 13:01.980
Uh, size of items.

13:03.120 --> 13:03.630
And.

13:08.080 --> 13:10.810
Size of my items and.

13:10.810 --> 13:11.230
Yeah.

13:12.360 --> 13:17.100
We will use the index and zero here.

13:17.220 --> 13:18.090
So that's it.

13:18.510 --> 13:19.950
Let's actually run our program.

13:19.950 --> 13:21.510
I think it will give it an error.

13:21.510 --> 13:24.270
Yes, it will give a no return statement, the function.

13:24.270 --> 13:32.490
So, yes, we need to return statement here, return my count, and let's run the program again.

13:32.490 --> 13:34.530
And as you can see here, we get an error.

13:35.880 --> 13:37.560
The thing is.

13:42.980 --> 13:45.500
Undefined reference to the list list here.

14:10.520 --> 14:18.350
And as you can see here, the list that Conte will return as the conte of our race.
