multiset empty() function in C++ STL

The multiset::empty() function is a built-in function in C++ STL which checks if the multiset is empty or not. It returns true if the multiset is empty, else it returns false.

Syntax:

multiset_name.empty()

Parameters: The function does not accepts any parameter.

Return Value: The function returns true if the multiset is empty, else it returns false.

Below programs illustrates the multimap::empty() function:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// CPP program to demonstrate the
// multiset::empty() function
#include <bits/stdc++.h>
using namespace std;
int main()
{
  
    int arr[] = { 15, 10, 15, 11, 10, 18, 18, 20, 20 };
  
    // initializes the set from an array
    multiset<int> s(arr, arr + 9);
  
    if (!s.empty())
        cout << "The multiset is not empty";
    else
        cout << "The multiset is empty";
    return 0;
}

chevron_right


Output:

The multiset is not empty

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// CPP program to demonstrate the
// multiset::empty() function
#include <bits/stdc++.h>
using namespace std;
int main()
{
    // declaration
    multiset<int> s;
  
    if (!s.empty())
        cout << "The multiset is not empty";
    else
        cout << "The multiset is empty";
    return 0;
}

chevron_right


Output:

The multiset is empty


My Personal Notes arrow_drop_up

The function of education is to teach one to think intensively and to think critically

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.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.