VOOZH about

URL: https://www.geeksforgeeks.org/cpp/unordered_set-size-function-in-c-stl/

⇱ unordered_set size() function in C++ STL - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

unordered_set size() function in C++ STL

Last Updated : 5 Jun, 2023

The unordered_set::size() method is a builtin function in C++ STL which is used to return the number of elements in the unordered_set container. 

Syntax:

unordered_set_name.size()

Parameter: It does not accepts any parameter. 

Return Value: The function returns the number of elements in the container. Below programs illustrate the unordered_set::size() function: 

Program 1: 

Output:
size of arr1:5
The elements are: 5 1 2 3 4

Program 2: 

Output:
Size of arr2 : 0

Time complexity: O(1)

Comment