unordered_set functions in C++ Part -I

unordered_set

File unordered_set.h

Unordered sets are containers that store unique elements in no particular order, and which allow for fast retrieval of individual elements based on their value.

Keys are immutable, therefore, the elements in an unordered_set cannot be modified.

Internally, the elements in the unordered_set are not sorted in any particular order but organized into buckets depending on their hash values to allow for fast access to individual elements directly by their values (with a constant average time complexity on average).


Some of the functions of unordered_set


begin()This function returns a read-only (constant) iterator that points to the first element in the unordered_set.


bucket_count()This function returns the number of buckets of the unordered_set.


bucket_size()This function returns the number of elements in a given bucket.


bucket()This function returns the bucket index of a given element.


cbegin()This function returns a read-only (constant) iterator that points to the first element in the unordered_set.


cend()This function returns a read-only (constant) iterator that points one past the last element in the unordered_set.


clear()This function erases all elements in an unordered_set.


count()This function finds the number of elements with the specified key.


emplace_hint()This function attempts to insert an element into the unordered_set.


emplace()This function attempts to build and insert an element into the unordered_set. This function inserts a new element in the unordered_set if its value is unique.


empty()This functions returns true if the unordered_set is empty (i.e the size of unordered_set is 0).


end()This function returns a read-only (constant) iterator that points one past the last element in the unordered_set.


equal_range()This function finds a subsequence matching given key.


erase():  This function erases the element (or elements ) from the unordered_set.


No comments:

Post a Comment