cpp_set_library_methods
cpp_set_library_methods
The <set> library in C++ provides a collection of methods for managing ordered sets of unique
elements.
Below is a list of the common methods available, along with their arguments and usage examples.
1) Constructor
- set<T>()
- set<T>(initializer_list<T>)
- set<T>(const set<T>&)
- set<T>(set<T>&&)
2) insert()
- Usage: Inserts an element into the set if it's not already present.
- Example: set.insert(10);
3) erase()
- Arguments: iterator pos, const T& value, iterator first, iterator last
- Example: set.erase(10);
4) find()
- Arguments: const T& value
6) size()
- Arguments: None
7) empty()
- Arguments: None
8) clear()
- Arguments: None
- Example: set.clear();
9) begin()
- Arguments: None
- Arguments: None
11) rbegin()
- Arguments: None
- Usage: Returns a reverse iterator to the first element of the reversed set.
12) rend()
- Arguments: None
- Usage: Returns a reverse iterator to the past-the-end element of the reversed set.
13) max_size()
- Arguments: None
- Usage: Returns the maximum number of elements the set can hold.
14) swap()
- Example: set1.swap(set2);
15) emplace()
- Example: set.emplace(10);
16) emplace_hint()
17) equal_range()
18) lower_bound()
- Usage: Returns an iterator pointing to the first element not less than the given value.
- Example: auto it = set.lower_bound(10);
19) upper_bound()
- Usage: Returns an iterator pointing to the first element greater than the given value.