hackingcpp / comments

Comments regarding hackingcpp.com
0 stars 0 forks source link

cpp/std/associative_containers #27

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year 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 1 year ago

Extract & (Re-)Insert Nodes :

Change Keys Without Copying It :

       auto n2 = m.extract(2);
       m.key() = 5;  -->  n2.key() = 5;
hackingcpp commented 1 year 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 10 months ago

erratas in the section Make Keys Hashable

should be

neuroevolutus commented 10 months 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.