size of unordered_set
// C++ program to illustrate the
// unordered_set.size() function
#include
#include
using namespace std;
int main()
{
unordered_set arr1 = { 1, 2, 3, 4, 5 };
// prints the size of arr1
cout << "size of arr1:" << arr1.size();
// prints the element
cout << "\nThe elements are: ";
for (auto it = arr1.begin(); it != arr1.end(); it++)
cout << *it << " ";
return 0;
}
size of unordered_set
// C++ program to illustrate the
// unordered_set::size() function
// when container is empty
#include
#include
using namespace std;
int main()
{
unordered_set arr2 = {};
// prints the size
cout << "Size of arr2 : " << arr2.size();
return 0;
}
|