Maps are associative containers that store elements in a mapped fashion. Each element has a key value and a mapped value. No two mapped values can have same key values.
empty() function is used to check if the map container is empty or not.
mapname.empty() Parameters : No parameters are passed. Returns : True, if map is empty False, Otherwise
Input : map mymap['a']=10; mymap['b']=20; mymap.empty(); Output : False Input : map mymap.empty(); Output : True
Errors and Exceptions
1. It has a no exception throw guarantee.
2. Shows error when a parameter is passed.
Time Complexity : O(1)
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Check if a string can be split into two strings with same number of K-frequent characters
- Difference between cout and puts() in C++ with Examples
- Difference between forward list and list in C++
- Short-Circuiting in C++ and Linux
- First subarray with negative sum from the given Array
- Different types of range-based for loop iterators in C++
- Count quadruplets(A, B, C, D) till N such that sum of square of A and B is equal to that of C and D
- Learn C++ Programming Step by Step - A 20 Day Curriculum!
- Smallest number to be added in first Array modulo M to make frequencies of both Arrays equal
- Most frequent element in Array after replacing given index by K for Q queries
- Check if Array elements can be maximized upto M by adding all elements from another array
- Count of elements which cannot form any pair whose sum is power of 2
- Array sum after replacing all occurrences of X by Y for Q queries
- Why do we need reference variables if we have pointers
- Similarities and Difference between Java and C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.