Set and Map collection in salesforce

Salesforce Development Using Apex Set and Map collection in salesforce
1 hour 1 minute
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€46.41
List Price:  €64.99
You save:  €18.57
£39.85
List Price:  £55.80
You save:  £15.94
CA$68.38
List Price:  CA$95.74
You save:  CA$27.36
A$75.69
List Price:  A$105.97
You save:  A$30.28
S$67.65
List Price:  S$94.71
You save:  S$27.06
HK$390.96
List Price:  HK$547.38
You save:  HK$156.41
CHF 45.35
List Price:  CHF 63.50
You save:  CHF 18.14
NOK kr542.95
List Price:  NOK kr760.18
You save:  NOK kr217.22
DKK kr346.22
List Price:  DKK kr484.74
You save:  DKK kr138.51
NZ$83.20
List Price:  NZ$116.49
You save:  NZ$33.28
د.إ183.60
List Price:  د.إ257.06
You save:  د.إ73.45
৳5,484.79
List Price:  ৳7,679.15
You save:  ৳2,194.35
₹4,174.22
List Price:  ₹5,844.24
You save:  ₹1,670.02
RM236.85
List Price:  RM331.61
You save:  RM94.76
₦61,737.65
List Price:  ₦86,437.65
You save:  ₦24,700
₨13,903.63
List Price:  ₨19,466.20
You save:  ₨5,562.56
฿1,842.69
List Price:  ฿2,579.91
You save:  ฿737.22
₺1,612.90
List Price:  ₺2,258.19
You save:  ₺645.29
B$253.75
List Price:  B$355.28
You save:  B$101.52
R922.13
List Price:  R1,291.06
You save:  R368.92
Лв90.85
List Price:  Лв127.20
You save:  Лв36.34
₩67,969.88
List Price:  ₩95,163.27
You save:  ₩27,193.39
₪185.94
List Price:  ₪260.34
You save:  ₪74.39
₱2,861.35
List Price:  ₱4,006.12
You save:  ₱1,144.77
¥7,722.34
List Price:  ¥10,811.89
You save:  ¥3,089.55
MX$843.21
List Price:  MX$1,180.56
You save:  MX$337.35
QR182.28
List Price:  QR255.22
You save:  QR72.93
P678.57
List Price:  P950.05
You save:  P271.48
KSh6,648.67
List Price:  KSh9,308.67
You save:  KSh2,660
E£2,385.52
List Price:  E£3,339.92
You save:  E£954.40
ብር2,869.28
List Price:  ብር4,017.22
You save:  ብር1,147.94
Kz41,825.96
List Price:  Kz58,559.69
You save:  Kz16,733.73
CLP$46,485.20
List Price:  CLP$65,083
You save:  CLP$18,597.80
CN¥354.33
List Price:  CN¥496.09
You save:  CN¥141.76
RD$2,899.21
List Price:  RD$4,059.13
You save:  RD$1,159.91
DA6,716.85
List Price:  DA9,404.13
You save:  DA2,687.28
FJ$112.23
List Price:  FJ$157.14
You save:  FJ$44.90
Q388.45
List Price:  Q543.86
You save:  Q155.41
GY$10,455.72
List Price:  GY$14,638.84
You save:  GY$4,183.12
ISK kr6,977.10
List Price:  ISK kr9,768.50
You save:  ISK kr2,791.40
DH500.96
List Price:  DH701.39
You save:  DH200.42
L885.56
List Price:  L1,239.86
You save:  L354.29
ден2,861.59
List Price:  ден4,006.46
You save:  ден1,144.86
MOP$402.29
List Price:  MOP$563.24
You save:  MOP$160.94
N$920.44
List Price:  N$1,288.69
You save:  N$368.25
C$1,839.55
List Price:  C$2,575.52
You save:  C$735.96
रु6,679.37
List Price:  रु9,351.66
You save:  रु2,672.28
S/186.27
List Price:  S/260.79
You save:  S/74.52
K193.32
List Price:  K270.67
You save:  K77.34
SAR187.48
List Price:  SAR262.50
You save:  SAR75.01
ZK1,358.11
List Price:  ZK1,901.47
You save:  ZK543.35
L231.01
List Price:  L323.43
You save:  L92.42
Kč1,161.35
List Price:  Kč1,625.98
You save:  Kč464.63
Ft18,056.25
List Price:  Ft25,280.20
You save:  Ft7,223.94
SEK kr542.25
List Price:  SEK kr759.20
You save:  SEK kr216.94
ARS$44,003.90
List Price:  ARS$61,608.98
You save:  ARS$17,605.08
Bs345.36
List Price:  Bs483.53
You save:  Bs138.17
COP$195,270.45
List Price:  COP$273,394.26
You save:  COP$78,123.80
₡25,568.20
List Price:  ₡35,797.53
You save:  ₡10,229.32
L1,234.61
List Price:  L1,728.55
You save:  L493.94
₲373,712.67
List Price:  ₲523,227.64
You save:  ₲149,514.97
$U1,909.55
List Price:  $U2,673.53
You save:  $U763.97
zł200.30
List Price:  zł280.44
You save:  zł80.13
Already have an account? Log In

Transcript

This conference will now be recorded. Okay. So in the previous session we have discussed about the list and the topics, okay, architectural topics, how it works and different type of directives. And out of the collection page, we discussed the book list. Okay, we talked about, it's an ordered collection of elements. And we have seen the examples of all the methods that we can use CMI, as I said that day, we have three types of lakes and remember, one I said it's the least one I said it's a set on one, its map, okay.

And we discuss in detail what it is. So today we'll see what he said and how we can use in mind Salesforce and what are the predefined methods, even by Salesforce to use it the financing said, so pass we will understand what is this set and how can I declare the set and how we can use all predefined methods. So if you remember In the list I said it is ordered collection of elements. So that means in which order you enter, it will store elements in the memory in the same sequence, okay, but when I say set it is on our collection of elements for a sum of unique elements, so there is a basic difference coming between list and said. So, list can contain duplicate elements, but when I said it is always unique elements, and it is the on order collection of unique elements.

So, what did it mean? Nice to see, let me make a small diagram for you. Okay, I'll just start with all basic concepts here. Okay. So who will help you to understand the core part of the source? So when I create a set, nothing but it is going to be a collection elements, okay?

Something like this. Okay. I'm just going to create one memory in system okay. So in the heap memory will create a memory. So, all the elements is going to be stored in one particular index Okay. So now when I said it is nothing but an ordered collection of elements okay.

So can I say that something like this set is nothing but on ordered collection of elements okay and all the elements should be unique which is the specific criteria or I can say a sweet feature of the set where all elements should be unique elements we cannot store any duplicate element in the set Okay, that is a password. So, now what happened if I entered if I try to enter some value we called 250 okay and if we try to enter the next element as 50 if you see in the list it will be stored like this, but here No, the moment is tried to store 250 and 50 It will check what was my previous window Okay, if my previous fellow is bigger than that, then the sale is going to be going to be replaced okay. So here it will come on to him it is going to come automatically this element is going to be saturated, okay?

Nothing but set is always in sorted order. And now we'll see how I can declare set in my system. So like we create a list to create a set, we have to use the set keyword, okay. So, like I said, whenever declare any variable as integer variable, we do integer, let's see, number one, equal to some value. And so it's going to content and get one even if I want to store collection of integer elements, okay, so I can use list or set as our now I'm going to set type. So said use the keyword said and what is the data type of this.

Okay? Then give the set name equal to then allocate some memory The moment you write this, so, it is going to create one memory location on making memory which we can use in the program. Okay. So now in the same time as on that cue that hidden memory can be accessible and whatever the collection elements will store all can be used. So now if you see Isa, you want to create one collection of integer type, what do you do set, then what type of collection you want to create, I want to create integer type of condition. So I associate an integer datatype.

Then I give them my name, I end set equal to a new set of integers. So it's simple thing. The moment you want to create any set collection, just you have to use like this set data type and the collection name. The moment you do this one, nothing about in memory, it will create one location. Okay. And if you see a name, array or Any other others collections, we need to specify the total number of element I'm going to store okay, but here I am not specifying how many limits can be stored on this leaf.

Whenever you are going to add a limit in dynamically it's going to create one new memory location is nothing but in the same memory location it's going to add one more memory Okay, all these things is going to be represented as one address, okay nothing but if I say T i in the least we hit the reference name of my memory location where I can store all the element vendors, okay, is going to create like that. So now, the moment I did set in detail, this one nothing work. I just create one empty collection of type integer. Okay, let me see programmatically pay go and do it what will happen. Okay, the same as the last time we did this, we did the program. So in this collection program, same way I'm removing all the stops.

I'm just going to write said so to create a set What'd you hear? I just played setup in digital CMR you can create set of strings that have double any values, set of integer. Let's just give our end set one equal to new set of string. So instead of integer Okay, if you Now you try to relate the list collection and set collection methods, okay, the moment I do this one and trying to do system dot debug what will happen here, let me put your print this, okay? If a do end set one. Okay, so what print value I'm going to print?

Let me execute it. If I click it, then just see what is my lock on to you. So I'm just clicking on debug only. I'm seeing it empty set for me. I have nothing I have some memory allocated, but there is nothing it's empty. So see, if I don't allocate this memory what will happen I don't have any memory here.

Just I gave it a name. There is No memory allocation there is no new keyword with the whenever you see a new keyword is nothing but it is allocating some memory from my hip memory to this collection or to this variable. Okay, so the if I don't allocate any memory I try to decode See, there will be a little bit difference series it is come coming as normal because I don't have any Memorial edition but if you see the previous one, I have something polymerases so there is a memory located but my collection is empty. So, here my collection is completely normal, I don't have no elevation system doesn't know where it is okay. There is a divergence I just remove this now I have a empty collection variable which we call a empty set one of type set of integers Okay. Now, like in the list we are the limits.

So if I say that I have written this collection like this set it anticipate one new certainty here nothing but as I said, it is going to create just one dummy collection okay nothing but it is like this now, the more it will be just just like this I have something. So, under the name what we are given we have given the name of INTJ to him. So, if you see, now, this collection having a name, call us I indiscipline This must only I have no. So, now I want to store some value on this. On this exam, I want to keep around to add some value on this. So, there are a few methods given by Salesforce which you can use to add elements on these same ways what we discussed in the list.

Same way, if you want to add an element in the collection, what you do here, I have a method called our method. We can use the Add method to add any element to this list to this set. Okay sim our method we can use So, now if you see if I go to this program Let me open that in meanwhile whenever you have any question stop me and ask me I won't mind anything I feel all your doubts okay. So, if I go here I will just try to do it said towards Dadar nothing but I am going to adding one element to this collection, okay what is my collection type integer So, I cannot add any string type of data here it will try to do it See, if I'll try to do adding of this string type of data to here try to decode it will give me some methods.

See, it's trying to do some string addition and this is nothing but we don't have this collection is payment integer. And if I'm trying to add string it will say it's incorrect signature in German not matching. So it's expecting integer but and passing the string. So, it should always told the same type of element what I have declared as a database Now I just stored here, two particular, same way I didn't go into I'm going to store another element, which I call. Let's see last thing. It's 35.

Same way, I'm going to store another element, which I call 151 45. Okay, same way, I'm going to store one more element, which I call 545. Okay, now see if I'm going to print this. Okay? So before it say, at least type, you don't print up to 4525 135 45. But it just said I extend past the set is nothing but it's an order on our collection of elements.

It will sort by different nothing What if I try to execute it? If you see let me show you the debug log. See you 25 then 145 then 245 then Piper By, so by default, this, all the collection elements are settled. Okay, so let's see if I try to put one duplicate elements 145. I'm trying to add multiple times. Okay, so added Saturday elements, so both the both the index cannot have the same elements.

So if you see if uploading them duplicate elements, it's nothing, it's unique always set contains unique elements below any question. No, perfect. Okay, so now, whenever you want to add a restricted domain, simply we used our method. Okay, so let's see, I'm just going to create another collection, another set collection. And in that collection, I'm going to add some more elements with addition to this. Same way how we have the list.

So what I'm going to do here, I'm going to create a empty set to Okay, the name I gave us In this way too. So now in our industry to I want to add all these elements, and I listen to that I may have some other elements when they say that, but what I do, I don't want to again write all this is what are the elements I have? I don't want to try it. Again Are you interested to to to like that. So I don't want to copy individual elements, I have some methods, which will help me to add a collection elements collection of elements on this on this set. So nothing about as I explained in the least, we have at all same way here also, I have one method, which we call Ardell.

Mockingbird, I can do is set to dot audible. So going to add a naughty word it is expecting a collection of elements, it may be a list of set of same thing. You can pass a list here or set here, but this type should be saved. So now I am just using this third one, what are the elements I have on my end stage? One take that and with that individual also I cannot form elements if you want to add a single element, the new job if you want to add collection of elements, the new model Okay, now I'm just going to print I indices these are the same methods what we have in the list same type of things, but this list set map we are going to use many times in the program. So, if you see any logic any class you will sees this collection this knowledge Okay.

So now if I navigate if you see I have two collections now, the insert one insert to insert one all the elements copied and with that, I have added something called my date okay. So see if you are it is automatically sorted again, wherever the elements but all elements will be inserted ordered. Okay, so now you understood what is our what is our How to alkalis and deliver how to order single delivers. Okay, now, let's see I want to see how many limits I have on buying to sell to nothing but I have a method which we call is set to the size. Okay? Same way it's going to return one digit number of element Okay, let's same way apart kalise metal I have I'm just spending all the same kind of metals here now, okay.

So I in the set to content, some elements up on the shape nothing but if you want to take the collision content family living simply you can use the side method you could now you see here, I got the collection of elements, number of elements, which contains indices. As you can see here, number of elements, number 2192 3455 elements we have on this collection. Okay? And now I want to clear all elements simply same way how we have lists clear, same way I can feel my all elements from interstate one, you can go here and just go into state one dot clear what will happen? Okay, so now I'm going to let me print both I in the state one in district two and they said two and also I want to print in the state one wants a clear what is going to happen okay, I just have to put it here No, I have I initiate one completely empty initially, then I have this many elements tonight in this shed to I have the syllables number of years time they make clear and if you see my industry one is completely cleared.

There is no elements of what I am to say to I have eluded I may add all collection of elements or initial one to two what is the different memory locations is nothing but I used We are cloning anything here is just complete just taking the elements and storing on different locations. So see I have it set to have all the elements but I in this one got cleared. Okay, so if you want to clear the elements, all the elements from a collection, simply simply use clear method. Okay, so now I want to see my see right now you can see a guy in this head to have some elements or not. Okay, so if you're a very big line of code, I'm getting data from my database and you will want to check okay this element particular element is gone is available on the collection or not, if you want to check that kind of thing, how will check sorry for example, later on the check, don't evaluate the limit exist on AI in this head to or not.

So, what it can do simply you can check if it said to dot contents, okay. So if we want to check you have single element contents on this collection are not simply huge contest method, what is the element I wanted to mention? If it contains, then it will return true if not, it will return false. So, understand your Boolean exist 25 or not. Okay? So I just go here I print system dot debug we'll see what is the value in these 25 exist or not okay.

So, you see if you go here you treasure good now see if the element exists and it will return me true if not, it will not return me in English 25 is true that means a element called 25 here if I want to check in show 25 I want to check some other value which is not included some it will give me false. So, is this is for a single elemental check, but if I undertake the collection of elements I have not nothing but I only checked there is I have one list type of collection here of integer. Okay, I mentioned it at least one at least contents to equal new list of integers. Okay, here's our regular marring elements here like this. Sorry, I haven't let's consider I'm just considering 145 25 and 545 you even you can add all the elements like this also.

Okay. So now, if I want to check this list of elements contents on the ad set to or not what you can do, so same way you can come here, just use instead of contents I want to check all the elements of another collection contents on this collection or not. So my current and current collection is I interested to I only check all this collection list collection what I created right now its content by this set or not. Okay. Let I give the name of this correction. If you go here We will see you what is happening okay see I mentioned content contents when you mention it will take immediately one element, but I'm passing a collection of elements not even what I have do is condense all.

So, I am going to check contents all element from this collection on my end say to each all elements are contained then I will return true otherwise false if you see here and if you see the debug log after execution my all elements there or not if yes then I will get output which through the all elements that you have. So, now on this collection, I'm adding one more element who is equal to L. So, now I get it. Now, you see, my all elements are not current, not contents on that collection. So return maples this way You can check all the livers contents or not. Okay, so now same way if you want to remove one particular element, then use remove. So let's see, from this set, I want to remove the element called 98.

In blue what it can do, I end set to dot remove, huge eliminate and remove or remove the element called 98. It will try to find out the element 90 and remove from the collection. Okay, so now I see a D here we can see where the difference came now. Let's open debug log. In now on this collection, I don't have 98 or before I had 98. Same way if you want to remove the list of columns, nothing we'll see From this collection I want to remove all 145 20 pay pay for default to whatever the element match I want to remove so that I can use a empty set to dot remove all whenever you are manipulating with another collection.

Always use all remove all forget are all contains all that kind of thing when you do these collection to remove so I just used remove all and I gave the collection name. Again I'm just going to aggregate we'll see the locator you know No, my even liquids only 245 Okay, so now same way as a mid remove. I just want to check my collection is empty or not. So now I have one eliminate the collection. epi J. Mine Collison is empty or not what we'll do, okay again, I'm doing Empty final.

Okay, you can give any any variable name, I'm just giving variable names so that we can understand on this context, okay, let's I am taking eg empty it is nothing but going to return me a Boolean bulletproof, for that I get Boolean. Whenever you use if condition equals condition that then we will use, okay. So that all the stuffs I'm going to explain when you learn about more advanced concept, okay, so see I just check here, I just indicate if you go here and open it the debug log it's not empty believe that one element if I don't have any label or an element, then it will so completely empty the same way under three yoga and I know I have removed all the elements from it set one. If I try to keep it as I end set one check, obviously to GMT. So it will submit true let me load this log It's empty, but I just stick with a innocent one.

Okay, so now, till now, do you have any question for me. So there was, likewise we were using in a list, because we have indexes over there, that means we can add or remove a specific value from a specific location. We can't do such thing in set, right? Instead, you cannot do it index because he here, it's all about the element as we do automatic sorting sorted here. So it's not manipulating with index. So if you want to get the element from index one, so being the next time that that element matches and because automatically will start to the intimate or to enter it maybe though, replace the value so we don't manipulate these are the index.

But still if you want to manipulate the index, you can use the archetype of the Not like you can get off these dark methods we cannot use, but we can use them for low and we can assess it and get each element you know think about for example to soil this one let's see I have this collection I end set to Okay, I have pure limits. So I can write it for low any I am going to talk about follow call. So in my one system, I can do here integer, each element, okay? Or simply I can write integer, each element, okay. And I'm just going to take I in this head too. So here, I can get all the elements in that way.

Okay, not with individually using get method or something. Okay, so get and set we won't be that means that that can't be used in set, right? No, that that is not a predefined method. Okay. Perfect. So now we learn how to remove a limit To add element to check this identity or everything semi, I have a special special method here, which we call the tensile.

So nothing but let me show you here something in mentalism right in all your selenium, I have 23 I have 45 I have 87 I have 98 I want to literally I have another collection, which I have 33 and 98. So, now, when I use remove, so, what happened the moment I use remove all then from this collection 2398 got removed. So, finally what is left out, left out 4587 and one one degree correct. So, I likewise, I have a retinal, he used the retinal instead of removal. So, it will remove everything except these elements. Okay?

That pain is part of the collection elements I have from that place on, just return these elements Remove others if you want that if you use removal that means remove these two elements from the collection and keep other elements if you retain all that means remove other elements keep only these two there is a big difference. So now same way how would you remove all same way we have a U turn on Okay, so right now see I just comment this symbol here. Okay so that I don't want to remove all the elements to check my emails are there or not? So now see, I just go here. I just made it said to retain all okay, and I'm just going to check the elements as you understood the mobile same way I'm just showing you little. This if you see the log file going to demobilize left with only 245 this 145 25 545 got removed because see I have this 145 25 pay but now I'm saying no written this Remove orders.

So if an activity is what happened see all eliminate similar maladies collection elements stored in the dataset. Okay, so you can use this one also the same way, if you want to clone one element, you can clone method also. Okay, so let's see what we're going to do here. So I have one one list 31 said, Who would you apply this to I want to clone This is a two to another method. Basically we use this clone normally, whenever you calculate with a subject records, nothing would account record or any custom object records. But still, we can use the clone method here to see if I'm just going to create another set here.

Let's see. I just mentioned near the close Okay. So now the payment center here, I nt said to clone multimode. It will clone cooperatively I interested to hear let me turn this 230 I just made some new diagnostic integers in the e n t years. Let me copy this Like how would you do list cloning, same way we can do the searcher cloning also said completely same mechanism or singles. We will see completely what eliminate I have in the ad set to everything will clone to my new clone set or something to completely I'm just calling it so after this clone now I'll just show you something here.

Once a cloning and then I just go and clear the iedc to I just cloned the element from it said to clone it. And then I went and clear it. Okay. So the moment they clear we'll see what are the limits I have in the indices and loans it is up loans and the past printer pink I interested to know I go on into let me load this to a blog in this had to be done. competently macloan shouldn't have that Hello okay. So when you see these things is nothing but this clone completely used as a deep clone, okay, it is completely cloned the memory location and eliminate is not the reference clone, not the clone that the two thing which we'll call the clone and select local when we talk deep learn is nothing but completely copy of that including the memory location, when you say select clone it is not the completely clone it is no it is just reference to the same object.

Nothing but let me explain you logically, but we'll just talk this in future in some other part. So, consider this is one of my collection Okay, this is one one my one of my collection. So now, so if I want to clone this I have to have sense. So I can make completely same part of this. Okay, I can refer in some areas, however, for this one. Otherwise, you I don't want to make the copy of this this one completely.

So, what will happen? Let me clear it. So, if you want to use it you just give it a name and refer to this place okay I just said pluralist okay nothing but you can use this with a reference to this just a reference to this okay. So, you can make another clone list something and just make a reference. So, that will come as a solid clone it is not completely clone just to clone the reference, but we are using the back end same object or same collision or same emulation. And when you say deploy one image completely and get copy of the same thing, but both are two different memory.

So, if we manipulate something here, it is not going to reflect on this one. If we monitor something on this men collection, it is not going to reflect here for that time. called torpedoes the floor. Okay, so we'll talk about this deeply in future Okay, just I gave the overview of that what is the opponent's alone Okay, so like that how we create the list same way we create the list and how list can be nested. Same way set can have the type nested type level natural we can make the set. Okay?

So I hope you have dude that liftmaster so for one level, Whitman mention our set of integer. Okay, so let's see I end set equal to a new set up integer. So if I want many levels, nothing but set up the collection elements the same way how we have in the map we have in a list. This is going to contain another set element of what type integers Okay, then now give this nested setname equal a new setup, this is what type of limit it is going to contain set up other elements same ways nothing but I have a list. Let me clear this completely. I have one set, I have one other set here and under set here, here I just have some element values.

I have some even village here, I have some even villager on timber, I declare all these collisional set of integer up is at one end said I have Judo one to five Samurai discoloration content civilians. Now, I want to have another lesson which can contain each element not as a list not as an integer or any predefined time. It can store this element completely. Nothing but it is going to store another list. Same ways, how would you paint this Emily said also and these said can be the initial set and you have to practice this one so that you can understand how we're going to play it below any confusion, any question for me no perfect. See the asuni all clear Okay, perfect.

Okay. So now we have another collection map. So, we understood list is an ordered collection of elements, which can contain duplicate values sated on other collection of delivers, which is unique. So, we understood why we have a list and said there is a difference, okay, so I may need my duplicate elements to be so stored, so we kept the list if I want no they all elements would be unique to you. To set I went okay my aim is to be sorted by default I can do set diver no mind even can be stored as the way I entered it can be released. So that to collision are we have understood then what is mapping them?

So quite map this is what kind of Alexandria when we say map it is nothing but a key pair collection. I think we're going let me say something here. Let me period Okay, you have seen the books, okay. So when you open the books past you see the index in the index number, you see what you see chapter numbers in three chapter. Okay, and here's number Same way, you see chapter two, and page number, you see separately, and some page number that way. So now nothing Word, if you see the page number that if you can go to chapter let's see, you see this page number 345 you can go to this chapter say ABC pills number 135 you can go to chapter two directly.

So nothing but you are navigating to a particular place by using some key. So, if you see chapter two cannot be existing multiple pages, there are two is going to be in the one page only. Okay 20 page no 45 no 450 or page number anything, but it is unique always. I cannot write anywhere in the book you will never see. Okay, chapter three again at page number 56. And again, you will not see anywhere in chapter three at page number 67 it may be chapter 3.1, but it will not be chapter three.

So, if you want to go to chapter three, what you will do, you will see plasma physics directly open pencil basics. Okay, so This kind of thing when you see this is nothing but we call it as a map and this map divided into four is a twofer whenever you see the map map is a collection of key and value pair. So we think this area is nothing but key the left side one and this is nothing but a Hello okay. So by seeing the Hello see this can be duplicate Okay, I can have one chapter 3.2 in page number 67 also can be it says multiple sections of on small comparables, I can be in the same page, but this load cell key cannot be duplicate anytime. Okay. So math is nothing but a collection of key and value pair where key is unique and how you can be duplicate.

So whenever occasional timbered. He's always remember he just said that it is already settled. And Hulu is always a list type. Okay, so now how I can use this map how I can create the map in senseless and incomplete until now getting to understand this concept is easy but while implementing it for me is really tough because it was tough, but I assure you it will be really easy. Okay, just we have to remember three to four methods for the map which you will use common always. And how to declare nothing else.

Don't worry, I'll assure you it's quite easy. Okay. Okay. So now Same way, when we declare this said all list we use list and set keyword. But when you use a map How will do it? Notice user magic If you were always if you want to declare a map use a map keyword.

So now, as I said mapping nothing but collection of key and value. So, I have to define what is my key to thing, what is my key what type of data you want to store the key, and whatever data you want to store the value to things. So now, like least least what what we did, or said what we did least, and we define that maybe string or integer anything. Okay? And then give the name an equal new so but here, this is the one type of data you're storing. bought in the map, we're going to store two types of data one is key one is value.

So what type of data you can make as a key? So that you define here, so past nothing but data type called key? Okay, and second one is going to be data type for Hello. Okay. Now give you a map name equal to new mapper dirty. perky.

And the refer. We handle this a little bit. Okay, we did this thing for it. So now we'll see. Let's consider I want to create a map okay? We student roll number and their name for example.

So I want to store okay I'll see the roll number I can get the name. So what I'm going to do, I am going to do map Okay, let's see, I say integer and string day. I'm explaining with a basic example. Okay, then what I do here, let's I give all numbers student map equal to new map of integers. Okay. So now if you do this one not anymore in the memory, exactly one empty map dated okay nothing but this is some kind of integer and this is some kind of string going to store more there is nothing.

So now, if you create an empty map how are we are going to show the elements? Let me see that but let me store this save this file somewhere for my future reference below any confusion, I don't think so colored. No. Perfect. So now the moment I go to create a map I use map they might type a dependent integer and the holotape a definitive string. I gave the name of the method rolls through in map equal new.

I've activated map, integer, string. Okay, so now it's a empty map. So how the element I'm going to store on this map, okay? Like, if you remember, in least your said we use our method. So when I want to add some element on this how I'm going to do so just I'm going to change my definition here, my sentence here. So I am going to add one value to a particular key.

Okay, nothing very fishy. I'm going to give my page number to a particular chapter. So I'm going to put one page number to each chapter, I am going to put to one page number on each chapter, same way, I am going to put values to a key. So instead of our methods, I am going to use a method which a call put method, okay? So if you want to put one element With a particular key, boo tip Hello for a particular key, we can use put method. So nothing but let's see, I use rules for now.

So nothing but how I'm adding the elements here instead of our use put method, put what value put hello to a key. So let's assume I roll numbers 123 and string nothing but ICP devices, same way. I have a map, I want to put another element, nothing but I use roll number 124 name age asuni. Okay. So say I want to put another name as one to five, namely three. Okay.

Same thing I'm just doing again, nothing else. So the moment I do this one, if you see all these elements, I'm adding on the memory of rosewood mouth 123 and let's see, I just mentioned here as is. Okay, so now this is a you will see if let me print this one. But in a funny moment you got confused, feel free to ask me. I'm just going to interpret this. See, the moment I activated what will happen?

It will so as me as key and Bolivia to me. So if you see here, see 123 equal to the verses one to four equals 21 to five equals V, one to six classes. So the moment let's see, I just want this is also either one to five if I try to save it, okay, so something happened, but what happened here? And you did, I just kept one to five as a duplicate key to me. So the more negative duplicate What is going to happen here see 123 verses one 2% one to five passes. So what is my lattice fellow it with the the, there will be no duplicate elements.

So if you have duplicate always be replaced okay see I have four elements but here I have only three. So, if you have duplicate key, it is going to be replaced with the largest or the largest data element will be stored only. So, that means if you want to put one element, okay to a key use put method if you have let's see, I have another collection. Okay, that I kept the name is roll live industrial map for example. And in this map I want all this names with something else. Same way how huge are all we lose?

Put on? Okay, I want to put all the elements From this collection is the same way how with other matters and apart from that we can use some other elements also. And always remember key is going to be unique. If not unique, then it will replace them Hello. Let's see I have 226 he asked Hello can duplicate I'm coming to 26 in assets two tents it can be no it's okay. And it's going to hear 206 minus i just think about it, let me print this also.

But the power of these methods power of this collision you will see you when you when you work with that I was so curious for you to get the record from database and manipulated that image the power of it, but right now to use that time right now we need to understand the methods to understand the syntax of that scenario see 1-231-234-1235 then the second element what we build okay how you can duplicate but key cannot be. So, now we know if you want the manipulated map What do we have we have put put all that we can use Okay. So now from this collection okay I want all the elements which are using key How will get I want all the elements which we have been added Hello How will get So, going I want all the elements which are used as a key simply we can go you can use a method Let me see, and key is always said I said key Jolla set and value added list.

If I want to store all the elements of the key what I do here is I gave you a set name. Okay. So type is integer as my key table integer. Okay, let's say Amundsen key from doralee. Okay, equal a new set of integers. Okay.

The moment is Dude, this And I want to get all the elements of the set. So here, nothing but I used odd all the elements, it may multiple elements always. So now from these collection, I want to get all the keys that are the input.is it he said a method which is going to return me all the elements which we have as a key, this part. Okay, see if I get it and go to print this part is what I'm getting here. Just integrate easier, I got all 11 1-231-241-3512 3232126 all the elements I got for you. Same way if I want to get all the elements which are used to us.

Hello. So what do you what do we do we have a method called Hello, let's see, is belu always at least not a set? Okay, and what is the type? Well hello, it's a string type, I just specify a string. So what I want to get so let's see, I'll get I just mentioned the name is Bella Bella from this map painted. So instead of key set, I'm using the values.

Let me print it. Okay. You have this all the vendors. See whenever you see the map right now any class you open or you lose to this port Method monitor ins to other elements, okay, we know how to put the limits how to get the elements from the key set, how to get the elements from the values. Okay? Now same way if I want to get a particular element from a key, okay, I want Okay, I'll go to rule number 123 and get the name devices to get a particular element from the key what do you do here?

So let's see I'm in the roles roadmap. Okay, so I want to get a particular element. So what do we do roadmap dot get element from the key What is my key? My key is 123. Right? So it's over here 123 key and get the element it is going to return me my Hello What is mentality let's just in them okay.

So in the moment I use gate nothing but add to string get the element for a specific key Mikey was 1.3. And I want to get what value I have there. So if I do that, and I will create using get element is going to give me the particular value for that key is included. Now, you see, on 103 I had the value as the versus if you see them given the verses in the one with the values is to get a particular element from from the key, use get key. Okay? So same way you can use underwriting you can use to check keys map is not empty or not, you can use each empty method which will return to the channels.

If the elements are empty CMR you can use size how we use window set in the body the collection size it will so if i in this map, I have 1234 I can get the four elements. So, if you see this map, I have four plus five plus six. So, I have six elements, okay? So if you want to check them Eliminate empty or do you want to get total number of elements user size methods? Yeah. So, now, from this the elements I want to remove the element which we have on the key 123 I want to remove this.

So simply what I can use this map dot remove, you can usually move or the invert I am going to remove one element from a key one point this element I want to remove. After remove, I just want to print that element completely. You see right now once I do it, and I just go on he goes, let me show you that 11 got removed so you can remove a particular element from it. Okay. You want to click on so if you want to remove all the elements CMI how you we use clear use the clear method With these things you can practice it pyramid okay how you clone one map set a list same way you can clone also. So, these are all methods which we use for a map okay.

So, any questions below? No. So, earlier Can we get a key as well from a value in a more liquid okay. So we can do that we can we can go niversary but we can write a for loop and we can we can try to get it in the logically but we can we can okay okay perfect. So, there is one more method which is called Get a solid state I will not talk about that now, one day talk about this okay lesson, so that I can show you how to get the object type of this map. Okay.

So what you do now, so you just practice this list set map and the mental switch is really important to be exporting epics gasunie from this methods do you have any confusion? Right now? I don't think so, but I will go through the to all the winners and perfect and let me share lychee who knew this matter being so confused What is this big area very very well we can confuse because this some time they used to boot and then after the retreat or data with the particular methods. So this sometimes get bit confused for me So, okay, so nothing but I can give you a small example. So which can play pay Allah. Okay, I'll write some kind of a circle right now.

Okay. So don't worry for that. Nothing but let's I have some form of here. Let's I am just calling an account this kind of thing I'll tell you completely in future classes. I just wrote select ID okay. Name disputing from account.

So I have very few records on my system. So title and putting all the stuffs provisional, right like that. But for example, I'm just writing it and I'm storing all this account in a map. Okay, now let's see string and let's see I have got nothing but account okay? So I just gave him a sec map equals new map of string and account so nothing but on this sec map I'm just storing all the elements account limits with key as account quality and completely account okay so this is not confusing too long correct? We can do this simply by simply type as account ISIS your account record, so sometimes what happened, I may need to get a particular phone list from somewhere.

We got it Have one account Ready? Okay, let me get this account ready something here and it's opening so as we get going on my system there is more or less knowledge of what I'm doing. But in future we'll, we'll use many many more of this kind of thing and just copying the record ID here who you should not do anything. But to explain this I'm just I just need this one. So, if I want to get the account details of this ID What am I can do I can you see this account ID nothing but one ID who is stored here. Okay, associate to this ID I have complete details of the account, which we have created.

If I want what I can do, I can get account, okay, map account, the name I gave. So, if I say map dot get a do here. And I pass it by passing this FCC ID Nothing but this is a test. I'll get the complete account it'll say system dot debug NAB sec, dust. I'm just printing this one. I'm just going to integrate only this much by using a highlighter but it means something omnisphere token This is a cc ID so I'm gonna have musing something interesting here as he was getting Norris explaining Let me see the lock pages.

See, Teddy? I got them all. I don't have anything so okay let me look at some memory here pastiche never gone. Is this homophone benign? Let me print call this accounts ID. So I just speak 123 account IDs because because my It can be 218 digit.

So based on that, it's definitive, it will take up it. So I just, I will just copy one specific ID here. So that Id I'll just try to put as a key just weird for a second. See ISIS tagging the last three digits with this specific ID. So it will give me the 18 character sensitive SOC seven and what it should be this ID which we didn't get by the copy. Now I'm just going to get that record to the specific record it may intimidate.

If you see I'll get that account permissions. So if you go to any any program wherever you have used map, you read that we will see a count to it. This name is completely came this one okay. So that type of thing we do here, okay? Nothing but what I'm saying here. So, we always whenever we map we lose this put get always okay?

And EMT and size you can improve MC EMT size booth get remove that kind of microphone levels and this kind of thing where you practice a lot we will get it as soon as we do get any confusion from this but yeah, this so key right now. Mm hmm. get noticed. So we'll practice so many of these okay. So we'll be expert and also if you have any specific scenario, any surgery program where you are confused, share with me in person I listen you will get clarity regardless even the basic examples. So not to confuse you a little bit just to see examples.

So based on that we will continue okay. Yeah. Perfect. So We'll meet next session where we'll discuss about to some more other topics. You Meanwhile, you practice this elite set and map. We'll meet again in the nation, if any questions we can discuss and you can message me or post any question to me at any time.

Yeah, sure. Yep. Thank you so much.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.