1 00:00:01,110 --> 00:00:02,350 Heidi this is so hard. 2 00:00:02,370 --> 00:00:05,070 And welcome to the next video of this collection. 3 00:00:05,090 --> 00:00:10,270 More do we now in this video we will check out varchar immutable set and they will. 4 00:00:10,410 --> 00:00:15,470 So first of all let us start with the immutable set by using the set of keyword. 5 00:00:15,570 --> 00:00:19,400 So here insert the intelligent ID largely modify my code. 6 00:00:19,800 --> 00:00:25,620 So here I have simply written to a command line does say it contains the unique elements that has shared. 7 00:00:25,620 --> 00:00:30,280 Also contains the unique elements but the sequence is not guaranteed in the output. 8 00:00:30,300 --> 00:00:33,890 Right now let me explain you what is a set first. 9 00:00:33,930 --> 00:00:39,670 So to define a set or in simple words the immutable set you can simply use that ARE. 10 00:00:40,500 --> 00:00:43,110 My set equal to. 11 00:00:43,400 --> 00:00:45,540 See set of keyword. 12 00:00:45,540 --> 00:00:48,080 This contains the list of objects. 13 00:00:48,150 --> 00:00:54,840 It simply expects that template let have a set of elements of integer type and insert this. 14 00:00:54,870 --> 00:00:57,080 You have to simply define the values. 15 00:00:57,130 --> 00:01:04,880 Let's say to the 4 3 1 0 and nurturing 9 9 and 9. 16 00:01:04,890 --> 00:01:11,850 Again at last 8 this sort of Metford actually returns are immutable set that can only support the read 17 00:01:11,850 --> 00:01:14,020 only operation and correctly. 18 00:01:14,040 --> 00:01:18,290 I have only these set of elements that is the interior values. 19 00:01:18,360 --> 00:01:24,570 So if you want to insert the string values then simply give their type as string and similarly simply 20 00:01:24,570 --> 00:01:25,820 give their type as float. 21 00:01:25,830 --> 00:01:32,180 If you want the Florida values but as of now I want the integer values for this more value right now 22 00:01:32,250 --> 00:01:37,620 since this is immutable in nature so we can not modify the mice set later on. 23 00:01:37,620 --> 00:01:40,950 That is you cannot insert more elements to it. 24 00:01:40,980 --> 00:01:46,620 You can only perform the operations such as size stream contains and so on. 25 00:01:46,650 --> 00:01:49,030 You can not add or remove the elements. 26 00:01:49,200 --> 00:01:56,450 Now to print out the elements from this might say we need to use the for loop and up inline statement. 27 00:01:56,890 --> 00:01:57,530 So for this. 28 00:01:57,570 --> 00:01:59,130 The chords are very simple. 29 00:01:59,130 --> 00:02:03,550 I will simply use element or any other variable you want. 30 00:02:03,610 --> 00:02:14,400 In keyword my sig and now insert this let us print out the elements such as element and remove this 31 00:02:15,010 --> 00:02:17,710 command and all of you are good to go. 32 00:02:17,720 --> 00:02:25,290 Let us note in the chord so in the output console we can see some Viride output initially to 54 triva 33 00:02:25,290 --> 00:02:26,220 and 0. 34 00:02:26,250 --> 00:02:30,010 OK but after this we have only 9 here. 35 00:02:30,190 --> 00:02:35,200 But while inserting the elements we had 3 9 instead of 1 right. 36 00:02:35,300 --> 00:02:39,550 So how come these two are getting removed from the set now. 37 00:02:39,570 --> 00:02:42,900 Initially I told you the search contained the unique elements. 38 00:02:43,050 --> 00:02:48,870 So no matter how many elements of the values of 9 you insert it will automatically be removed from the 39 00:02:48,870 --> 00:02:54,630 set because it is the property of the set that it can only contain the unique elements so that hidden 40 00:02:54,690 --> 00:02:58,200 elements will be removed and no duplicate elements will be present. 41 00:02:58,260 --> 00:03:02,790 Right so that is why see that certs only contain the unique elements. 42 00:03:02,790 --> 00:03:08,480 Now suppose you want to modify your set so far that you need to use the mutable set. 43 00:03:08,490 --> 00:03:15,890 Now again we need to change this set off to see new table set of integer values right. 44 00:03:15,930 --> 00:03:22,470 So this will simply return on your table set which simply means that later on you can again modify your 45 00:03:22,480 --> 00:03:24,740 search such as my search dog. 46 00:03:24,900 --> 00:03:28,510 Remove any element such as I want to remove this 54. 47 00:03:28,770 --> 00:03:32,790 So I will simply use 54 here and then run the code. 48 00:03:32,820 --> 00:03:39,580 It will simply strike out the element off of default from our set and now the 54 is now gone. 49 00:03:39,620 --> 00:03:45,890 So that is why we see that this new table set off does mutable set right and we can perform the read 50 00:03:45,920 --> 00:03:51,970 and write Operation Boot no later on if you want to add some element so we can simply use my assert 51 00:03:52,070 --> 00:03:55,200 and don't add and simply add legacy. 52 00:03:55,260 --> 00:03:57,290 Hundred and run the code. 53 00:03:57,300 --> 00:04:00,810 So in the output we have hundred as a last element. 54 00:04:00,810 --> 00:04:04,650 Now this new set of actually returns the same object. 55 00:04:04,650 --> 00:04:05,120 Right. 56 00:04:05,250 --> 00:04:06,270 Now what about this. 57 00:04:06,270 --> 00:04:08,340 Now what about this hash sake. 58 00:04:08,430 --> 00:04:11,060 So far this let me show you one more example. 59 00:04:11,430 --> 00:04:17,930 So instead of murid able to set off you can simply use hash of. 60 00:04:18,050 --> 00:04:20,820 Now this will simply return the object of hash. 61 00:04:20,830 --> 00:04:26,960 So right now if you are from a Java background then you must be knowing what this hash sect stands for. 62 00:04:27,170 --> 00:04:32,900 It also contains the unique elements but the only difference between hash sake and said is that in the 63 00:04:32,900 --> 00:04:37,540 hash sicht the sequence is not guaranteed in the output which means that. 64 00:04:37,670 --> 00:04:41,070 Suppose I have two fifty four three and so on like this. 65 00:04:41,180 --> 00:04:42,140 And right. 66 00:04:42,300 --> 00:04:46,280 But for this set it will simply print or the values in the sequence. 67 00:04:46,310 --> 00:04:50,100 But for the hash set the sequence does not matter. 68 00:04:50,300 --> 00:04:55,310 And it does not guarantees that the elements will be rendered in the same sequence. 69 00:04:55,310 --> 00:05:00,190 So as of now let us check out what happens in the output console. 70 00:05:00,230 --> 00:05:04,220 So for this also let's just comment out remove and add operation. 71 00:05:04,310 --> 00:05:10,880 Let us note in the chord and NIXEY of the elements are being entered in the sequence or not. 72 00:05:10,890 --> 00:05:18,960 So here you can notice I have 0 1 2 3 54 8 and 9 the elements are not being entered in sequence because 73 00:05:19,380 --> 00:05:25,030 the zero which is being printed as a first element it is actually present in the middle of all the hash. 74 00:05:25,040 --> 00:05:28,480 So that and also this nine is actually printed at the end. 75 00:05:28,530 --> 00:05:31,350 But it is present at the second and last element. 76 00:05:31,350 --> 00:05:37,880 So the sequence in case of hash is not guaranteed but in case of set it is actually guaranteed. 77 00:05:38,070 --> 00:05:44,580 So the only difference between the two they will off and hash set off is this only of the sequence. 78 00:05:44,580 --> 00:05:51,100 So you can use either of these to ask but are you a requirement that they will accept and Buddh supports 79 00:05:51,180 --> 00:05:58,240 read and write operation that is you can remove elements add element or replace any element and so on. 80 00:05:59,030 --> 00:06:01,650 So finally we have reached the end of this more deal. 81 00:06:01,670 --> 00:06:06,980 So in this more will we talked about the collections collections and collections and also it talked 82 00:06:06,980 --> 00:06:13,600 about the immutable collection and mutable collection in all the cases of list map and set. 83 00:06:13,640 --> 00:06:20,330 Now if you remember all these mentors such as list of map of and set off and all these methods that 84 00:06:20,330 --> 00:06:24,230 I have mentioned here add a list of hash map off and so on. 85 00:06:24,320 --> 00:06:28,200 You will face new difficulty for their data structure in Carter-Long. 86 00:06:28,370 --> 00:06:34,200 So make sure you remember there are differences between the immutable and mutable collections and the 87 00:06:34,200 --> 00:06:37,330 respective metrics of least map and stick. 88 00:06:37,340 --> 00:06:41,060 So this is considered signing off and thanks for watching and have a good day. 89 00:06:41,060 --> 00:06:41,840 Thank you.