Map In C++

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 พ.ย. 2024

ความคิดเห็น • 127

  • @LoZiOcErCa
    @LoZiOcErCa 4 ปีที่แล้ว +164

    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 ปีที่แล้ว +15

      because we need to pass exams and want a job. It's in our blood.

    • @hackein9435
      @hackein9435 4 ปีที่แล้ว +2

      @@vinoddiwan5792 true, getting job is too hard, and the competition!

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว +11

      Thanks dude..

    • @yashwantmoharil5892
      @yashwantmoharil5892 4 ปีที่แล้ว +1

      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 ปีที่แล้ว +2

      @@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 !!!!!!!!!!!!!!!!!

  • @gurdeepmundi6440
    @gurdeepmundi6440 4 ปีที่แล้ว +28

    I am paying a bunch of money in a Canadian University and learning from you fella, you are awesome.

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว +2

      Thanks man..

    • @vinayak186f3
      @vinayak186f3 3 ปีที่แล้ว +1

      Fr to India wapas aaja bhai

    • @vikaspai294
      @vikaspai294 3 ปีที่แล้ว

      sorry for being racist,but why do most punjabis go to canada?

    • @arpitchugh7297
      @arpitchugh7297 3 ปีที่แล้ว +2

      @@vikaspai294 We have a lot money and very little methods to spend it.

  • @mjjala934
    @mjjala934 3 ปีที่แล้ว +7

    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 ปีที่แล้ว +1

      Wao...
      Instant results.. 😀

  • @ajinkyapatil3599
    @ajinkyapatil3599 3 ปีที่แล้ว +2

    Hats off to your work !!!
    I really do appreciate your presence here on TH-cam behalf of all our developers community. 👏🏻👏🏻👏🏻

  • @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 ปีที่แล้ว +1

      Yes, i forgot to mention this i guess.

  • @markusbuchholz3518
    @markusbuchholz3518 5 ปีที่แล้ว +14

    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 ปีที่แล้ว +1

      Sure man!!
      Today it self this thought crossed my, sure i will try this in future.
      Thanks for the suggestion and comment.

  • @fromdjangoimport__help__3585
    @fromdjangoimport__help__3585 3 ปีที่แล้ว

    Better and more professional than code with harry , lol!

  • @AnkurSingh-uo4vo
    @AnkurSingh-uo4vo 4 ปีที่แล้ว +8

    that cleared my concept on maps

  • @shivamkumarsingh1420
    @shivamkumarsingh1420 4 ปีที่แล้ว +1

    hey mr rupesh your knowledge of c++ is good and your explanation is exellent .keep it up!

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Thanks a ton

  • @senthilandavanp
    @senthilandavanp 5 ปีที่แล้ว +2

    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.

  • @TorontoWangii
    @TorontoWangii 2 ปีที่แล้ว

    Nice tutorial, simple and straightforward!

  • @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!

  • @mahesh4274
    @mahesh4274 4 ปีที่แล้ว +3

    Thank you youtube algorithms for suggesting this video, just what I wanted, subscribed... liked...

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว +1

      Thanks man!!

    • @mahesh4274
      @mahesh4274 4 ปีที่แล้ว +3

      @@CppNuts no no no , i should thank you, so thank you

  • @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 ?

  • @shadowwoodsman3624
    @shadowwoodsman3624 4 ปีที่แล้ว +4

    Thank you, CppNuts! I can now work on my data structures assignment with a better idea lol

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว +1

      Thanks...
      All the best..

  • @neelpatel122
    @neelpatel122 4 ปีที่แล้ว +1

    Perfectly explained👏

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Glad you liked it

  • @msbabjan2341
    @msbabjan2341 5 ปีที่แล้ว +2

    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 ปีที่แล้ว +1

      Thanks man..
      Sure i am trying my best..
      You will get it soon.

  • @dhanushambrose4179
    @dhanushambrose4179 4 ปีที่แล้ว +3

    thank you so much,All these concepts telling how the high level programing languages evolving .

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Thanks man!!

  • @gauthampracharya9592
    @gauthampracharya9592 4 ปีที่แล้ว +1

    Thanks for the great explanation!

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว +1

      Thanks man..

  • @amanbhardwaj5318
    @amanbhardwaj5318 5 ปีที่แล้ว +2

    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 ปีที่แล้ว +1

      Sure 👍

  • @learningisfun3791
    @learningisfun3791 2 ปีที่แล้ว

    Sir in the multiset video why //for(const auto & e:multiset) I didn't understand it could you clarify. Thank you

  • @ylmazalperen1194
    @ylmazalperen1194 4 ปีที่แล้ว +7

    Hello Sir ! I didn't understand meaning of auto&ell : m . Anybody help me for explanation.

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว +4

      th-cam.com/video/dvaqLnbdEcM/w-d-xo.html

  • @aby_yadav
    @aby_yadav ปีที่แล้ว

    Rupesh, I am wondering how index operator must be working on underlying BST!

  • @cloudyric1647
    @cloudyric1647 4 ปีที่แล้ว

    I can not thank you enough for this video.

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว +1

      Glad it helped!

  • @JV-ld3oq
    @JV-ld3oq 4 ปีที่แล้ว +1

    I have subscribed, need more videos like this.

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Thanks..
      Sure..

  • @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 ปีที่แล้ว +1

      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

  • @venkateshn9884
    @venkateshn9884 4 ปีที่แล้ว

    Awesome bro...Keep on doing in cpp

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Thank you, I will

  • @heathledger7291
    @heathledger7291 4 ปีที่แล้ว

    thank u so much for putting out such good quality videos on stl.

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว +1

      Glad you like them!

  • @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 ) {

  • @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.

  • @senthilandavanp
    @senthilandavanp 5 ปีที่แล้ว +2

    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 ปีที่แล้ว +1

      They are different.

  • @kirantirth5137
    @kirantirth5137 3 ปีที่แล้ว

    Can you please tell how to add comparison operator in case of a user defined class?

  • @khushboo2229
    @khushboo2229 4 ปีที่แล้ว +1

    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.

  • @karthickkumar1380
    @karthickkumar1380 3 ปีที่แล้ว

    God You;

    • @CppNuts
      @CppNuts  3 ปีที่แล้ว

      Thanks dude..

  • @Leon-rt9lt
    @Leon-rt9lt ปีที่แล้ว

    thanks for this great video

    • @CppNuts
      @CppNuts  ปีที่แล้ว

      You are welcome

  • @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?

  • @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 ปีที่แล้ว +1

      @
      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.

  • @JV-ld3oq
    @JV-ld3oq 4 ปีที่แล้ว

    Excellent, Thank you very much

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      Glad it was helpful!

  • @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

  • @teetanrobotics5363
    @teetanrobotics5363 4 ปีที่แล้ว

    Bro could you make a tutorial on map-filter-reduce in stl ?

  • @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 ปีที่แล้ว +3

      if you dont use reference (&), then it will create copy everytime, and you dont want to do that because of size complexity

  • @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.

  • @ehashanrabbipial9411
    @ehashanrabbipial9411 4 ปีที่แล้ว

    sometime we use map['a']++ with out setting its initial value . Does map sets 0 at key 'a' automatically?

  • @srijakatipally4847
    @srijakatipally4847 4 ปีที่แล้ว

    May I know in which ide you are writing this code....

    • @CppNuts
      @CppNuts  4 ปีที่แล้ว

      VS Code.

  • @kaursnehjeet
    @kaursnehjeet 4 ปีที่แล้ว

    How to insert values in map through user input?

  • @jatinrauthan9075
    @jatinrauthan9075 3 ปีที่แล้ว

    loved it

    • @CppNuts
      @CppNuts  3 ปีที่แล้ว

      Thanks

  • @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.

  • @vikku_19
    @vikku_19 5 ปีที่แล้ว +1

    But ultimately there are two values for one key. How?

    • @CppNuts
      @CppNuts  5 ปีที่แล้ว

      Didn't get the question?

    • @vikku_19
      @vikku_19 5 ปีที่แล้ว +1

      @@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 ปีที่แล้ว +1

      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]

  • @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.

  • @berg.worldNow
    @berg.worldNow 2 ปีที่แล้ว

    God 👏🏾👏🏾👏🏾👍🏿

    • @CppNuts
      @CppNuts  2 ปีที่แล้ว

      Thanks..

  • @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

  • @विशालकुमार-छ7त
    @विशालकुमार-छ7त 3 ปีที่แล้ว

    I will graduate from TH-cam.

    • @CppNuts
      @CppNuts  3 ปีที่แล้ว

      This is what i want.

  • @khushijain4969
    @khushijain4969 3 ปีที่แล้ว

    👏

  • @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..

  • @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.

  • @sachinos
    @sachinos 3 ปีที่แล้ว

    chotu... hehehe

  • @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.