6. Map #
Created Sunday 03 May 2020
- Stores key value pairs.
- Uses hashing.
- mapn.insert(key, value)
- = does deep copy
- To check do .find(value) or .count(value)
- We can use man[key] = value can be used for insertion as well as retrieval.
- .at(key) is the same as mapn[key].
- When using the iterator, element->first is the key, element->second->is the value. Iterator points to the whole element block, not just the key or value.
- map is made using BST - logn
- unordered map is made using hashtable - O(1) for all ops.
- map supports ‘pair’ while unordered_map does not support it.