Related Articles

Related Articles

multiset empty() function in C++ STL
  • Last Updated : 20 Nov, 2020

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 accept any parameter. 

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

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



Program 1:  

C++

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ 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: 

C++

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ 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




 

Attention reader! Don’t stop learning now. Get hold of all the important C++ Foundation and STL concepts with the C++ Foundation and STL courses at a student-friendly price and become industry ready.




My Personal Notes arrow_drop_up
Recommended Articles
Page :