Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

unordered_map

unordered_map vs map : 
map (like set) is an ordered sequence of unique keys whereas in unordered_map key can be stored in any order, so unordered. 
The map is implemented as a balanced tree structure that is why it is possible to maintain order between the elements (by specific tree traversal).
The time complexity of map operations is O(log n) while for unordered_map, it is O(1) on average. 


at():        This function in C++ unordered_map returns the reference to the value with the element as key k.
begin():     Returns an iterator pointing to the first element in the container in the unordered_map container
end():       Returns an iterator pointing to the position past the last element in the container in the unordered_map container
bucket():    Returns the bucket number where the element with the key k is located in the map.
bucket_count:bucket_count is used to count the total no. of buckets in the unordered_map. No parameter is required to pass into this function.
bucket_size: Returns the number of elements in each bucket of the unordered_map.
count():    Count the number of elements present in an unordered_map with a given key.
equal_range: Return the bounds of a range that includes all the elements in the container with a key that compares equal to k.
find():      Returns iterator to element.
empty():     checks whether container is empty in the unordered_map container.
erase():     erase elements in the container in the unordered_map container.
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
5+2 =