Introduction
It is an associative container that store unique elements in no
particular order, and which allow for fast retrieval of individual
elements based on their value.
Definition
Below is definition of std::unordered_set
template < class Key,
class Hash = hash<Key>,
class Pred = equal_to<Key>,
class Alloc = allocator<Key>
> class unordered_set;
Parameters
- Key − It defines the type of element.
- Hash − It is a unary function object.
- Pred − It is a binary predicate that takes two arguments of the same type as the elements and returns a bool.
- Alloc − It defines the type of allowcater.
Member types
Following member types can be used as parameters or return type by member functions.
member type |
definition |
notes |
key_type |
It is the first template parameter (Key) |
|
value_type |
It is the first template parameter (Key) |
The same as key_type |
hasher |
It is the second template parameter (Hash) |
defaults to: hash<key_type> |
key_equal |
It is the third template parameter (Pred) |
defaults to: equal_to<key_type> |
allocator_type |
It is the fourth template parameter (Alloc) |
defaults to: allocator<value_type> |
reference |
Alloc::reference |
|
const_reference |
Alloc::const_reference |
|
pointer |
Alloc::pointer |
for the default allocator: value_type* |
const_pointer |
Alloc::const_pointer |
for the default allocator: const value_type* |
iterator |
a forward iterator to const value_type |
* convertible to const_iterator |
const_iterator |
a forward iterator to const value_type |
* |
local_iterator |
a forward iterator to const value_type |
* convertible to const_local_iterator |
const_local_iterator |
a forward iterator to const value_type |
* |
size_type |
an unsigned integral type |
usually the same as size_t |
difference_type |
a signed integral type |
usually the same as ptrdiff_t |
Member functions
Below is list of member functions
Capacity
S.N. |
Capacity & Description |
1 |
empty
It is used to test whether container is empty. |
2 |
size
It returns container size. |
3 |
max_size
It returns maximum size. |
Iterators
S.N. |
Iterators & Description |
1 |
begin
It returns iterator to beginning. |
2 |
end
It returns iterator to end. |
3 |
cbegin
It returns const_iterator to beginning. |
4 |
cend
It return const_iterator to end. |
Element lookup
S.N. |
Element lookup & Description |
1 |
find
It is used to get iterator to element. |
2 |
count
It is used to count elements with a specific key. |
3 |
equal_range
It is used to get range of elements with a specific key. |
Modifiers
S.N. |
Modifiers & Description |
1 |
emplace
It is used to construct and insert element. |
2 |
emplace_hint
It is used to construct and insert element with hint. |
3 |
insert
It is used to insert elements. |
4 |
erase
It is used to erase elements. |
5 |
clear
It is used to clear content. |
6 |
swap
It is used to swap content. |
Buckets
Hash policy
S.N. |
Hash policy & Description |
1 |
load_factor
It returns load factor. |
2 |
max_load_factor
It is used to get or set maximum load factor. |
3 |
rehash
It is used to set number of buckets. |
4 |
reserve
It gives a request to capacity chage of backets |
Observers
S.N. |
Observers & Description |
1 |
hash_function
It is used to get hash function. |
2 |
key_eq
It is used to get key equivalence predicate. |
3 |
get_allocator
It is used to get allocator. |
Predefined iterators
No comments:
Post a Comment