hackingcpp / comments

Comments regarding hackingcpp.com
1 stars 0 forks source link

cpp/std/associative_containers #27

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

C++ Standard Library Associative Containers | hacking C++

Learn about C++'s standard (STL) associative containers modeling sets, key-value maps and hash sets/maps.

https://hackingcpp.com/cpp/std/associative_containers.html

GuloWang commented 2 years ago

Extract & (Re-)Insert Nodes :

Change Keys Without Copying It :

       auto n2 = m.extract(2);
       m.key() = 5;  -->  n2.key() = 5;
hackingcpp commented 2 years ago

@GuloWang Thanks for spotting the typo! I fixed it.

heheda123123 commented 1 year ago

in section "Make New Sets/Maps", the template parameter of map is wrong

std::map<int> m1;
std::map<int> m2 {};
kooonnn commented 1 year ago

erratas in the section Make Keys Hashable

should be

neuroevolutus commented 1 year ago

In the Get Size / Query Emptiness section, I believe the code snippets m.insert(3,"x"); and m.insert(1,"y"); should be replaced with m.insert({ 3,"x"}); and m.insert({1,"y"}); respectively.