Map In C++

  Рет қаралды 138,903

CppNuts

CppNuts

Күн бұрын

Пікірлер: 127
@gurdeepmundi6440
@gurdeepmundi6440 4 жыл бұрын
I am paying a bunch of money in a Canadian University and learning from you fella, you are awesome.
@CppNuts
@CppNuts 4 жыл бұрын
Thanks man..
@vinayak186f3
@vinayak186f3 3 жыл бұрын
Fr to India wapas aaja bhai
@vikaspai294
@vikaspai294 3 жыл бұрын
sorry for being racist,but why do most punjabis go to canada?
@arpitchugh7297
@arpitchugh7297 3 жыл бұрын
@@vikaspai294 We have a lot money and very little methods to spend it.
@mjjala934
@mjjala934 3 жыл бұрын
Saw the video today morning for interview prep , got a question using map ds in my round-3, Solved it. And got placed, Thanx alott for making these videos....
@CppNuts
@CppNuts 3 жыл бұрын
Wao... Instant results.. 😀
@LoZiOcErCa
@LoZiOcErCa 4 жыл бұрын
It has become a joke, but the Indian (I assume you're indian) guy on youtube is always way better than any university professor on the globe!
@vinoddiwan5792
@vinoddiwan5792 4 жыл бұрын
because we need to pass exams and want a job. It's in our blood.
@hackein9435
@hackein9435 4 жыл бұрын
@@vinoddiwan5792 true, getting job is too hard, and the competition!
@CppNuts
@CppNuts 4 жыл бұрын
Thanks dude..
@yashwantmoharil5892
@yashwantmoharil5892 4 жыл бұрын
rightly said by vinod sir. From the beginning we have an impression that only if you do the conventional desk jobs,you'll get respect from society. maybe its wrong but the truth so everyone has to study
@nikhilpatil2482
@nikhilpatil2482 3 жыл бұрын
@@yashwantmoharil5892 i dont't know why collsege faculty's are more focus on conversation and personal development we have lots of stuff to learn in engineering , and we take just a 40% of importance to coding and project and 60% how to face interviews and all fuck this all !!!!!!!!!!!!!!!!!
@videofountain
@videofountain 5 жыл бұрын
An alternative is Map.insert({"LilSyntax",888}) for your example... The argument is a simple example of std::initializer_list ... This is a briefer syntax. std::make_pair is not always necessary today.
@CppNuts
@CppNuts 5 жыл бұрын
Yes, i forgot to mention this i guess.
@ajinkyapatil3599
@ajinkyapatil3599 3 жыл бұрын
Hats off to your work !!! I really do appreciate your presence here on KZbin behalf of all our developers community. 👏🏻👏🏻👏🏻
@markusbuchholz3518
@markusbuchholz3518 5 жыл бұрын
Hello Rupesh! Generally speaking all your videos are very useful and carefully done! The content is also great. I am very glad of being the member if your channel. It will be also great to present, beside "the theory" some small projects to utilize the theory in practice. Anyway., please continue your channel. Keep fingers for you!
@CppNuts
@CppNuts 5 жыл бұрын
Sure man!! Today it self this thought crossed my, sure i will try this in future. Thanks for the suggestion and comment.
@senthilandavanp
@senthilandavanp 5 жыл бұрын
Simple and amazing 1)map template structure 2)map key should be unique. different way to insert the values in map a)Map.insert(std::make_pair(key,value)) b)Map.insert(std::pair(key,value)) c)Map[key] ; in this case value will be default 3)How map is Internally implemented. self balance search tree how to traverse In-order 4) By default map is ordered in Ascending, If we want to sort in descending order we need to use mapMap. You used vector as value. Value can be anything.Vector or map or any object. Probably, you could have included the time complexity of inserting the element although most people know it.
@mahesh4274
@mahesh4274 4 жыл бұрын
Thank you youtube algorithms for suggesting this video, just what I wanted, subscribed... liked...
@CppNuts
@CppNuts 4 жыл бұрын
Thanks man!!
@mahesh4274
@mahesh4274 4 жыл бұрын
@@CppNuts no no no , i should thank you, so thank you
@AnkurSingh-uo4vo
@AnkurSingh-uo4vo 4 жыл бұрын
that cleared my concept on maps
@GilFavor101
@GilFavor101 3 жыл бұрын
Clutch! I just got help from reddit's r/cplusplus, and the code the guy/gal wrote had std::map in it, and I was JUST reading the docs on map, then I remembered you : ) Perfecto!
@shadowwoodsman3624
@shadowwoodsman3624 4 жыл бұрын
Thank you, CppNuts! I can now work on my data structures assignment with a better idea lol
@CppNuts
@CppNuts 4 жыл бұрын
Thanks... All the best..
@heathledger7291
@heathledger7291 4 жыл бұрын
thank u so much for putting out such good quality videos on stl.
@CppNuts
@CppNuts 4 жыл бұрын
Glad you like them!
@fromdjangoimport__help__3585
@fromdjangoimport__help__3585 3 жыл бұрын
Better and more professional than code with harry , lol!
@dhanushambrose4179
@dhanushambrose4179 4 жыл бұрын
thank you so much,All these concepts telling how the high level programing languages evolving .
@CppNuts
@CppNuts 4 жыл бұрын
Thanks man!!
@learningisfun3791
@learningisfun3791 2 жыл бұрын
Sir in the multiset video why //for(const auto & e:multiset) I didn't understand it could you clarify. Thank you
@TorontoWangii
@TorontoWangii 2 жыл бұрын
Nice tutorial, simple and straightforward!
@shivamkumarsingh1420
@shivamkumarsingh1420 4 жыл бұрын
hey mr rupesh your knowledge of c++ is good and your explanation is exellent .keep it up!
@CppNuts
@CppNuts 4 жыл бұрын
Thanks a ton
@amanbhardwaj5318
@amanbhardwaj5318 5 жыл бұрын
That's a great insight☺️. Please cover the working of unordered_map/unordered_set also in next videos. Reason I am asking this because i have tried to understand about how the collisions are handled in these unordered associative containers but still not sure how it is done exactly. It will be great if you can give some insights, from the time complexity point of view also.
@CppNuts
@CppNuts 5 жыл бұрын
Sure 👍
@ylmazalperen1194
@ylmazalperen1194 4 жыл бұрын
Hello Sir ! I didn't understand meaning of auto&ell : m . Anybody help me for explanation.
@CppNuts
@CppNuts 4 жыл бұрын
kzbin.info/www/bejne/mqfEon-kl8l4ma8
@sumakatabattuni5428
@sumakatabattuni5428 3 жыл бұрын
awesome tutorial !! I have a doubt. You have told that keys once created cannot be deleted, but by using erase ( ) function i think we can. Please clarify
@CppNuts
@CppNuts 3 жыл бұрын
Thanks, please specify what point in video I said that?
@sumakatabattuni5428
@sumakatabattuni5428 3 жыл бұрын
@@CppNuts at 9:12 you mentioned it as once created it remains forever.
@CppNuts
@CppNuts 3 жыл бұрын
The point is you always update the value not the key. That's how it is fixed and can't be changed. And yes with erase you can delete key and value both togather.
@sumakatabattuni5428
@sumakatabattuni5428 3 жыл бұрын
@@CppNuts ohh ok thankyou
@neelpatel122
@neelpatel122 4 жыл бұрын
Perfectly explained👏
@CppNuts
@CppNuts 4 жыл бұрын
Glad you liked it
@kirantirth5137
@kirantirth5137 3 жыл бұрын
Can you please tell how to add comparison operator in case of a user defined class?
@senthilandavanp
@senthilandavanp 5 жыл бұрын
I had a doubt but my program clarified .what if the key is string and the key Value is "aBC" "ABC" . Are these same or different and insert into the map.It is inserted
@CppNuts
@CppNuts 5 жыл бұрын
They are different.
@gauthampracharya9592
@gauthampracharya9592 4 жыл бұрын
Thanks for the great explanation!
@CppNuts
@CppNuts 4 жыл бұрын
Thanks man..
@JV-ld3oq
@JV-ld3oq 4 жыл бұрын
I have subscribed, need more videos like this.
@CppNuts
@CppNuts 4 жыл бұрын
Thanks.. Sure..
@lucasanddre
@lucasanddre 4 жыл бұрын
So can I say that a map is like an array of pointers? Each index is the value type and each pointer is a class?
@JohnWick-mk4ve
@JohnWick-mk4ve 4 жыл бұрын
one of the best explanations of maps.. sir can you also explain how to do search between two maps.. vlookup one column against keys of other maps and write to another file ?
@msbabjan2341
@msbabjan2341 5 жыл бұрын
I am following ur videos, and they r really helpful.Thanks for that. But i want to ask u when r u uploading Data Structures videos? Kindly do it soon..👍
@CppNuts
@CppNuts 5 жыл бұрын
Thanks man.. Sure i am trying my best.. You will get it soon.
@cloudyric1647
@cloudyric1647 4 жыл бұрын
I can not thank you enough for this video.
@CppNuts
@CppNuts 4 жыл бұрын
Glad it helped!
@AbdullahJirjees
@AbdullahJirjees 4 жыл бұрын
Hello and thank you for the video I am having this question assignment can anyone help me in this issue? interval_map is a data structure that efficiently associates intervals of keys of type K with values of type V. Your task is to implement the assign member function of this data structure, which is outlined below. interval_map is implemented on top of std::map. In case you are not entirely sure which functions std::map provides, what they do and which guarantees they provide, we provide an excerpt of the C++ standard here: Each key-value-pair (k,v) in the std::map means that the value v is associated with the interval from k (including) to the next key (excluding) in the std::map. Example: the std::map (0,'A'), (3,'B'), (5,'A') represents the mapping 0 -> 'A' 1 -> 'A' 2 -> 'A' 3 -> 'B' 4 -> 'B' 5 -> 'A' 6 -> 'A' 7 -> 'A' ... all the way to numeric_limits::max() The representation in the std::map must be canonical, that is, consecutive map entries must not have the same value: ..., (0,'A'), (3,'A'), ... is not allowed. Initially, the whole range of K is associated with a given initial value, passed to the constructor of the interval_map data structure. Key type K besides being copyable and assignable, is less-than comparable via operator< is bounded below, with the lowest value being std::numeric_limits::lowest() does not implement any other operations, in particular no equality comparison or arithmetic operators Value type V besides being copyable and assignable, is equality-comparable via operator== does not implement any other operations You are given the following source code: #include #include template class interval_map { std::map m_map; public: // constructor associates whole range of K with val by inserting (K_min, val) // into the map interval_map( V const& val) { m_map.insert(m_map.end(),std::make_pair(std::numeric_limits::lowest(),val)); } // Assign value val to interval [keyBegin, keyEnd). // Overwrite previous values in this interval. // Conforming to the C++ Standard Library conventions, the interval // includes keyBegin, but excludes keyEnd. // If !( keyBegin < keyEnd ), this designates an empty interval, // and assign must do nothing. void assign( K const& keyBegin, K const& keyEnd, V const& val ) {
@vighneshk509
@vighneshk509 4 жыл бұрын
can you please explain the for each loop with more detail or give some resources to understand it better??
@JustinK0
@JustinK0 4 жыл бұрын
@ Vighnesh Kadam whenever you iterate through a map you should have a loop like that if the map is called mp, you're not able to do mp.first or mp.second for (auto& m : mp)
@vighneshk509
@vighneshk509 4 жыл бұрын
@@JustinK0 thanks man understood it !!
@ashminjaysonashminjayson2348
@ashminjaysonashminjayson2348 3 жыл бұрын
In the last example can't we use a vector of pairs?? I meant the scenario in which he stated that we can't use vectors and arrays.
@Phawrillztho
@Phawrillztho 4 жыл бұрын
Can you expand on the comparison of data within two different objects? You mentioned a function. value_comp is exclusively for comparisons within the same object? I am not sure where you were going with that.
@venkateshn9884
@venkateshn9884 4 жыл бұрын
Awesome bro...Keep on doing in cpp
@CppNuts
@CppNuts 4 жыл бұрын
Thank you, I will
@aby_yadav
@aby_yadav Жыл бұрын
Rupesh, I am wondering how index operator must be working on underlying BST!
@destroyer20745
@destroyer20745 4 жыл бұрын
can you tell me how to practice and implement these topics??
@CppNuts
@CppNuts 4 жыл бұрын
You can use online programming competitions website
@destroyer20745
@destroyer20745 4 жыл бұрын
@@CppNuts but i dont think any online judge has some specific questions on this stl section
@karthickkumar1380
@karthickkumar1380 3 жыл бұрын
God You;
@CppNuts
@CppNuts 3 жыл бұрын
Thanks dude..
@JV-ld3oq
@JV-ld3oq 4 жыл бұрын
Excellent, Thank you very much
@CppNuts
@CppNuts 4 жыл бұрын
Glad it was helpful!
@kaursnehjeet
@kaursnehjeet 4 жыл бұрын
How to insert values in map through user input?
@shubhamshinde5643
@shubhamshinde5643 4 жыл бұрын
Are map dynamic ??????
@Leon-rt9lt
@Leon-rt9lt Жыл бұрын
thanks for this great video
@CppNuts
@CppNuts Жыл бұрын
You are welcome
@arunrajak.b8987
@arunrajak.b8987 3 жыл бұрын
Are maps implemented using hash tables or binary search tree, I have a confusion on this !!
@CppNuts
@CppNuts 3 жыл бұрын
Different languages use different things. Like Java Script uses hash map, where as C++ uses red black tree.
@shwetadalal1549
@shwetadalal1549 4 жыл бұрын
in the for loop when i remove the & operator it is giving the same output. Then what is the use of & in for statement??
@mehulchavda7712
@mehulchavda7712 4 жыл бұрын
if you dont use reference (&), then it will create copy everytime, and you dont want to do that because of size complexity
@vikku_19
@vikku_19 5 жыл бұрын
But ultimately there are two values for one key. How?
@CppNuts
@CppNuts 5 жыл бұрын
Didn't get the question?
@vikku_19
@vikku_19 5 жыл бұрын
@@CppNutsCppNuts you said, in a map, one key can have maximum one value but when we passed a vector, Amit had two values.
@Schoolroom9
@Schoolroom9 4 жыл бұрын
@@vikku_19 this is what im confused
@almosteasy9590
@almosteasy9590 4 жыл бұрын
@@Schoolroom9 Its simple... ' Key' is unique and value can be anything, since he added vector now, so values are now stored in vector. So its like [Amit ] : vector of values. Had it not been vector and int then 2nd value will replace first one.
@piyushkumar-wg8cv
@piyushkumar-wg8cv 4 жыл бұрын
he is correct in video, here Amit is pointing to a vector (although it is not name but let's say it is vector v1) Amit(key) -> v1[ 234123413 2343413] Chotu(key) ->v2[90909009]
@teetanrobotics5363
@teetanrobotics5363 4 жыл бұрын
Bro could you make a tutorial on map-filter-reduce in stl ?
@ehashanrabbipial9411
@ehashanrabbipial9411 4 жыл бұрын
sometime we use map['a']++ with out setting its initial value . Does map sets 0 at key 'a' automatically?
@sriramkrishnamurthy4473
@sriramkrishnamurthy4473 4 жыл бұрын
yes
@nikasbelogolov9019
@nikasbelogolov9019 4 жыл бұрын
How do I do nested maps like this one: { String: { String: String } }
@CppNuts
@CppNuts 4 жыл бұрын
Hi Nikas map if this is what you are asking.
@srijakatipally4847
@srijakatipally4847 4 жыл бұрын
May I know in which ide you are writing this code....
@CppNuts
@CppNuts 4 жыл бұрын
VS Code.
@jatinrauthan9075
@jatinrauthan9075 3 жыл бұрын
loved it
@CppNuts
@CppNuts 3 жыл бұрын
Thanks
@Schoolroom9
@Schoolroom9 4 жыл бұрын
at 2:01 you said, same same cannot have different values, but at 13:14 how , the key Amit has different values. :/
@sasoyu8922
@sasoyu8922 4 жыл бұрын
I think you did not get the point, my english is not well but i'll try to explain. At the beginning of the video he explained the concept of map as a collection of entries key-value (string as Key and int as value). If the map Is organized as a bucket at the generic key "k" you can store more values (as he did in the last part using Vector). This seems great but leads to a problem called "collision"
@JustinK0
@JustinK0 4 жыл бұрын
he said that you're not able to have 2 of the same key, even if the values are different but you are able to have 2 of the same value as long as the keys are different.
@BECE_SonamdeepKour
@BECE_SonamdeepKour 4 жыл бұрын
MY PROGRAM IS NOT WORKING AND ITS SHOWING THIS ERROR, PLEASE HELP C:\Users\best buy\Desktop\Coding C++\Example_Map\main.cpp|15|error: request for member 'first' in 'el1', which is of non-class type 'int'| C:\Users\best buy\Desktop\Coding C++\Example_Map\main.cpp|15|error: request for member 'second' in 'el1', which is of non-class type 'int'| ||=== Build failed: 2 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|
@aby_yadav
@aby_yadav Жыл бұрын
.first and . second should be applied on iterator, not on map object
@khushboo2229
@khushboo2229 4 жыл бұрын
Hey your videos have been really helpful for understanding the stl topic...😄 Can you please suggest me a platform where I can practice its basics so I can get a better command on this topic.
@CppNuts
@CppNuts 4 жыл бұрын
Thanks.. You can find map related problems in competitive programming and practice there.
@khushijain4969
@khushijain4969 3 жыл бұрын
👏
@berg.worldNow
@berg.worldNow 2 жыл бұрын
God 👏🏾👏🏾👏🏾👍🏿
@CppNuts
@CppNuts 2 жыл бұрын
Thanks..
@lakshaysingla2754
@lakshaysingla2754 3 жыл бұрын
Sir not good UNtill here i was able to grab some part of the concept but now u speeded up almost 5X and I lost my control and not able to udnerstand
@CppNuts
@CppNuts 3 жыл бұрын
i hope there is an option to slow down the speed of video in youtube.
@mdirshadalam2617
@mdirshadalam2617 3 жыл бұрын
Hi Rupesh, Please help me, I am not able to understood the below program how to correct ---------------------------------------------------------------------------------------------------------------------------------- #include #include using namespace std; typedef struct { int id; }Test; typedef struct { int x; std::map infoOfTest; }Resource; // We compare Test objects by their ids. bool operator
@CppNuts
@CppNuts 3 жыл бұрын
What part?
@aby_yadav
@aby_yadav Жыл бұрын
I can't see operator < for Resource structure.
@विशालकुमार-छ7त
@विशालकुमार-छ7त 3 жыл бұрын
I will graduate from KZbin.
@CppNuts
@CppNuts 3 жыл бұрын
This is what i want.
@premkumarsr4021
@premkumarsr4021 2 жыл бұрын
Letters are very small.. Pls zoom the screen and make videos
@CppNuts
@CppNuts 2 жыл бұрын
Now i shoot with bigger fonts thanks man..
@sachinos
@sachinos 3 жыл бұрын
chotu... hehehe
Multimap In C++
16:22
CppNuts
Рет қаралды 37 М.
Multiset In C++
10:20
CppNuts
Рет қаралды 38 М.
Мама у нас строгая
00:20
VAVAN
Рет қаралды 11 МЛН
Creative Justice at the Checkout: Bananas and Eggs Showdown #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 6 МЛН
Ice Cream or Surprise Trip Around the World?
00:31
Hungry FAM
Рет қаралды 22 МЛН
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 118 МЛН
Mutex In C++
16:22
CppNuts
Рет қаралды 110 М.
Optimized Way To Use Vector In C++
15:58
CppNuts
Рет қаралды 60 М.
std::set In C++
13:56
CppNuts
Рет қаралды 96 М.
STL std::map  | Modern Cpp Series Ep. 126
36:13
Mike Shah
Рет қаралды 4,1 М.
Vector In C++
14:11
CppNuts
Рет қаралды 95 М.
std::priority_queue In C++
11:15
CppNuts
Рет қаралды 56 М.
Мама у нас строгая
00:20
VAVAN
Рет қаралды 11 МЛН