More STL Containers
More STL Containers
map_insert.cpp
Searching std::map
map_lookup.cpp
Searching std::map
map_lookup.cpp
Searching std::map
www.apple.com: 398782126
The iterator points to the entire node in the
map, which is an std::pair!
map_lookup.cpp
Iterating Over an std::map
Use iterators and a for loop to print out all the nodes in the std::map.
map_loop.cpp
Iterating Over an std::map
www.google.com: 215183441
www.apple.com: 398782126
map_loop.cpp
www.utoronto.ca: 918567265
Accessing Elements in std::map
• operator[key]
• Returns a reference to the value
map_access.cpp
What will this output?
Google: 215183441
Microsoft: 0
Apple: 398782126
Ebay: 0
map_access.cpp
Duplicate Keys
Key exists.
Not inserted!
An insertion
takes place –
this is a
multimap.