Sets in CPP are used to store sorted key. They are the associative containers. Each key in a set is unique. CPP facilitates insertion and deletion of a key in a set but do not allow any modifications.
Member Functions of a CPP Set:
Allocator:
FUNCTION | USES |
get_allocator | To return an allocator object to construct the set. |
Capacity:
FUNCTION | USES |
empty() | To determine whether the set is empty or not. |
max_size() | To determine the maximum size of the set. |
size() | To determine number of elements in the set. |
Constructor/Destructor:
FUNCTION | USES |
(constructor) | To construct a set. |
(destructor) | To destruct a set. |
operator= | To copy the elements of the set to another set. |
Iterators:
FUNCTION | USES |
begin() | To point to the first element of the set. |
cbegin() | To return a constant iterator to the beginning of the set. |
cend() | To return a constant iterator to the end. |
crbegin() | To return a const reverse iterator to the beginning. |
crend() | To return a const reverse iterator to the end. |
end() | To return an iterator to the end. |
rbegin() | To return a reverse iterator to the beginning. |
rend() | To return a reverse iterator to the end. |
Modifiers:
FUNCTION | USES |
clear() | To remove all the elements of the set. |
erase() | To delete the specified element. |
emplace() | To construct and insert a new element at a specified position. |
emplace_hint() | To construct and insert a new element at a specified position by hint. |
insert() | To insert a new element in the set.. |
swap() | To exchange the contents of two sets. |
Non-Member Overloaded Functions:
FUNCTION | USES |
operator== | To determine whether the two sets are equal or not. |
operator!= | To determine whether the two sets are equal or not. |
operator<= | To determine whether the first set is less than or equal to other or not. |
operator< | To determine whether the first set is less than other or not. |
operator>= | To determine whether the first set is greater than equal to other or not. |
operator> | To determine whether the first set is greater than other or not. |
swap() | To exchange the contents of two sets. |
Observers:
FUNCTION | USES |
key_comp | To return a copy of key comparison object. |
value_comp | To return a copy of value comparison object. |
Operations:
FUNCTION | USES |
count | To get the number of elements matching with given key. |
equal_range | To get the range of elements matches with given key. |
Find | To find an element with given key. |
lower_bound | To get an iterator to lower bound. |
upper_bound | To get an iterator to upper bound. |