unordered_set empty() function in C++ STL
The unordered_set::empty is a built-in function in C++ STL which is used to check if an unordered_set container is empty or not. It returns True if the unordered_set container is empty, otherwise it returns False.
Syntax:
map_name.empty()
Parameters: This function does not accepts any parameter.
Return Value: It returns a boolean value True if the unordered_set container is empty, else false.
Below programs illustrate the above function:
Program 1:
// C++ program to illustrate the // unordered_set::empty function #include <iostream> #include <unordered_set> using namespace std; int main() { // declaration unordered_set<int> sample; // Check whether the unordered_set is empty if (sample.empty() == true) cout << "true" << endl; else cout << "false" << endl; // Insert a value sample.insert(5); // Now check whether it is empty if (sample.empty() == true) cout << "true" << endl; else cout << "false" << endl; return 0; } |
true false
Program 2:
// C++ program to illustrate the // unordered_set::empty function #include <iostream> #include <unordered_set> using namespace std; int main() { // declaration unordered_set<int> uset; // Insert a value uset.insert({ 5, 6, 7, 8 }); // Check whether the unordered_set is empty if (uset.empty() == true) cout << "true" << endl; else cout << "false" << endl; return 0; } |
false
Recommended Posts:
- multimap empty() function in C++ STL
- unordered_multiset empty() function in C++STL
- multiset empty() function in C++ STL
- unordered_multimap empty() function in C++ STL
- list empty() function in C++ STL
- Why to check both isset() and !empty() function in PHP ?
- map::empty() in C++ STL
- set::empty() in C++ STL
- match_results empty() in C++ STL
- array::empty() in C++ STL
- unordered_map empty in C++ STL
- Why is the size of an empty class not zero in C++?
- How to check whether an array is empty using PHP?
- Best way to initialize empty array in PHP
- Check if an array is empty or not in JavaScript
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.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.



