-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnordered_Set.cpp
More file actions
59 lines (46 loc) · 1.56 KB
/
Unordered_Set.cpp
File metadata and controls
59 lines (46 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <bits/stdc++.h>
using namespace std;
// unordered_set is an associative container that contains a set of unique objects.
// Search, insertion, and removal have average O(1) and worst case O(n).
void solve() {
// --- Initialization ---
unordered_set<int> us1 = {1, 2, 3, 4, 5, 10};
// --- Iterators ---
// begin(), end()
// --- Capacity ---
// size(), empty()
// --- Modifiers ---
// insert(value), insert(initializer_list), insert(it_first, it_last),
// insert(pos, value), emplace(args...), emplace_hint(pos, args...)
// erase(value), erase(pos), erase(pos_first, pos_last)
// merge(unordered_set)
// clear()
// --- Lookup ---
// count(value), contains(value)
// find(value)
// --- Bucket interface ---
// bucket_count()
// bucket(value), bucket_size(index)
// begin(index), end(index)
// --- Hash policy ---
// load_factor()
// max_load_factor(), max_load_factor(f)
// rehash(count), reserves at least the specified number of buckets and regenerates the hash table.
// reserve(count), reserves space for at least the specified number of elements and regenerates the hash table.
// --- Hints ---
// When using a custom class with an unordered_set, it's necessary
// to defineboth a hash function and an equality comparison for that class.
for (auto x : us1) {
cout << x << '\n';
}
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
return 0;
}