@7:39 Bucket Count (e.g., std::unordered_set s(5);) This is about organizing the internal storage with a specified number of buckets. Elements are distributed among these buckets based on their hash values. Suppose you insert an integer 14. The hash function calculates a hash value, let's say h(14) = 14 for simplicity. The bucket index is then 14 % 5 = 4, so 14 is placed into bucket 4. reserve(5);: This is about optimizing performance by minimizing the number of rehashes when inserting elements. It does so by ensuring there's enough space allocated to hold the specified number of elements without needing to rehash. Am I right?
Unordered set only contains keys, whereas unordered map is a key/value pair. (I.e. stores the keys, same as map, but those keys are used to index and return a value)
@7:39
Bucket Count (e.g., std::unordered_set s(5);) This is about organizing the internal storage with a specified number of buckets. Elements are distributed among these buckets based on their hash values. Suppose you insert an integer 14. The hash function calculates a hash value, let's say h(14) = 14 for simplicity. The bucket index is then 14 % 5 = 4, so 14 is placed into bucket 4.
reserve(5);: This is about optimizing performance by minimizing the number of rehashes when inserting elements. It does so by ensuring there's enough space allocated to hold the specified number of elements without needing to rehash. Am I right?
That sounds about right to me!
Thank you so much for wonderful underneath concept.
Cheers, you are most welcome!
Thanks Mike for this great video 🤩! I have a question why @23:36 we got that error? I didn't get it quite why.
I think I just had the wrong type -- needed an iterator that can insert.
may I know difference between unordered_set and unordered_map?
Unordered set only contains keys, whereas unordered map is a key/value pair. (I.e. stores the keys, same as map, but those keys are used to index and return a value)
can you provide me your vim step file and commands to use it.
I use a vanilla vim and occasionally code completion: ua-cam.com/video/IR6pfkqjbw8/v-deo.html