WEBVTT 00:01.560 --> 00:06.120 Welcome in this lecture, I'm going to talk about the capacity of facilities in more detail. 00:06.570 --> 00:07.750 All right, let's get started. 00:08.970 --> 00:11.890 This declaration creates a new slice like this one. 00:12.330 --> 00:17.420 This is a new slice, so it doesn't have a backing away, so all its fields are zero. 00:17.910 --> 00:22.230 So why use the land function or the function on this slice? 00:22.470 --> 00:24.210 Both will return zero. 00:26.170 --> 00:32.570 When I use a slice literal instead, this time God creates a new back here. 00:32.640 --> 00:35.380 There are three elements in this last Litoral, right? 00:36.970 --> 00:41.500 So that is why the age is this begging, Kerry has three elements as a. 00:43.360 --> 00:50.260 So the capacity is the length of the back injury of a slice, it is not the length of a slice, remember, 00:50.290 --> 00:53.680 a slice and its back injury are different values. 00:55.020 --> 01:02.820 So after creating the big Kerry, Gore returns a header here, the slides refers to the first element 01:02.820 --> 01:03.930 of its back injury. 01:04.320 --> 01:07.740 And after the first element, there are three elements in the array. 01:08.040 --> 01:11.070 So that is why the slicers capacity is three here. 01:11.670 --> 01:17.910 Socialises capacity is all about the length of his leg injury and where the slide starts. 01:20.650 --> 01:26.330 Since the age of Slice sees all the elements of its air, so its length is also three. 01:26.530 --> 01:32.110 So why use a slice Litoral directly, the capacity and the length of the slice will be the same. 01:32.830 --> 01:36.100 Let's slice the edges slice to create an empty slice from its. 01:37.700 --> 01:44.570 When I do so, it's length becomes zero, but its capacity remains the same, remember, as Selassie's 01:44.570 --> 01:51.650 capacity is all about its begging koray and where it starts, the slice doesn't have any elements, 01:51.650 --> 01:57.190 but it's Erra has three elements, and the slice starts from the first element of the era. 01:57.650 --> 02:00.650 That is why its capacity is still three. 02:02.100 --> 02:09.390 I can start this slice by using the available capacity inside its Pechanga, for example, let me assign 02:09.390 --> 02:10.740 this slice to a variable. 02:12.120 --> 02:16.740 And now I'm going to slice the aid slice up to its maximum capacity. 02:19.690 --> 02:23.050 I extended the slice back to its full capacity. 02:23.590 --> 02:30.130 I can do so because there was enough capacity in the back injury, so the capacity of fossilise determines 02:30.130 --> 02:31.480 how much you can extend it. 02:32.210 --> 02:36.150 Remember, as soldier's expression returns a newsless value. 02:36.400 --> 02:39.230 So the extended slice is not the original one. 02:39.460 --> 02:40.540 It is a new slice. 02:41.050 --> 02:43.120 By the way, I can do the same thing. 02:43.120 --> 02:49.470 Using the cap function like this is because the function returns the maximum capacity of a slice. 02:49.780 --> 02:57.520 So it returns three because the slices these three, let's try to extend the slice beyond its capacity. 02:58.390 --> 03:03.130 As you can see, I cannot do that because the slices Ceppos these three, not four. 03:03.460 --> 03:10.450 So you cannot extend the slice beyond its capacity is because there isn't enough space left in the begging 03:10.450 --> 03:11.290 array to do so. 03:12.240 --> 03:15.390 Anyways, let's return back and slice it differently. 03:19.600 --> 03:26.530 So after slicing it like this, the capacity becomes too, it's because these new slice is referring 03:26.530 --> 03:30.790 to the second element of the array and there are two more elements in the area. 03:31.390 --> 03:35.710 And its length is two, because it sees the last two elements of its air. 03:36.400 --> 03:39.790 Notice that the pointer is not for the eight anymore. 03:39.970 --> 03:41.170 It is 56. 03:41.780 --> 03:42.880 It is eight bytes. 03:42.880 --> 03:48.700 Memory s away from the first element, so the slice cannot see the first element of its baking array 03:48.700 --> 03:49.150 anymore. 03:51.470 --> 03:58.040 This time, the slide starts from the third element, this means that it cannot see the previous elements 03:58.040 --> 04:00.520 of the array for the slice. 04:00.740 --> 04:02.570 Its error has only one element. 04:02.960 --> 04:05.210 That is why its capacity is one now. 04:06.740 --> 04:13.820 This time, the slice is beyond the last element, so the slices capacity is zero is because for the 04:13.820 --> 04:16.670 slice, it doesn't contain any elements. 04:16.880 --> 04:20.840 Interestingly, though, the slice still points to the beginning of its array. 04:21.030 --> 04:27.170 However, you cannot use the previous elements so the pointer field isn't meaningful by itself. 04:27.320 --> 04:31.860 That is why the slice Heather needs to store the length and the cupboards, the fields as well. 04:32.420 --> 04:36.920 Let me assign the last slice exploration's result to the same slice variable. 04:37.520 --> 04:40.690 No slice there again, but I cannot do so. 04:40.880 --> 04:46.760 It's because God knows that the capacity of the slice is zero, so it doesn't allow me to extend the 04:46.760 --> 04:50.800 slice back even though it knows where its error is located on the memory. 04:51.230 --> 04:53.070 So value lost the original slice. 04:53.090 --> 04:55.550 Heather, you cannot extend it back as in here. 04:55.790 --> 04:59.450 If I hadn't overwritten the slice, I could have extended. 05:00.350 --> 05:00.800 All right. 05:00.980 --> 05:03.070 That's all for now in the next lecture. 05:03.140 --> 05:05.510 I'm going to show you an example in the coding, Ed.. 05:05.510 --> 05:07.750 So you can understand the capacity concept better. 05:08.060 --> 05:09.040 See you there by.