
- C標準庫
- C標準庫
- C++標準庫
- C++庫 - 首頁
- C++庫 - <fstream>
- C++庫 - <iomanip>
- C++庫 - <ios>
- C++庫 - <iosfwd>
- C++庫 - <iostream>
- C++庫 - <istream>
- C++庫 - <ostream>
- C++庫 - <sstream>
- C++庫 - <streambuf>
- C++庫 - <atomic>
- C++庫 - <complex>
- C++庫 - <exception>
- C++庫 - <functional>
- C++庫 - <limits>
- C++庫 - <locale>
- C++庫 - <memory>
- C++庫 - <new>
- C++庫 - <numeric>
- C++庫 - <regex>
- C++庫 - <stdexcept>
- C++庫 - <string>
- C++庫 - <thread>
- C++庫 - <tuple>
- C++庫 - <typeinfo>
- C++庫 - <utility>
- C++庫 - <valarray>
- C++ STL庫
- C++庫 - <array>
- C++庫 - <bitset>
- C++庫 - <deque>
- C++庫 - <forward_list>
- C++庫 - <list>
- C++庫 - <map>
- C++庫 - <multimap>
- C++庫 - <queue>
- C++庫 - <priority_queue>
- C++庫 - <set>
- C++庫 - <stack>
- C++庫 - <unordered_map>
- C++庫 - <unordered_set>
- C++庫 - <vector>
- C++庫 - <algorithm>
- C++庫 - <iterator>
- C++高階庫
- C++庫 - <any>
- C++庫 - <barrier>
- C++庫 - <bit>
- C++庫 - <chrono>
- C++庫 - <cinttypes>
- C++庫 - <clocale>
- C++庫 - <condition_variable>
- C++庫 - <coroutine>
- C++庫 - <cstdlib>
- C++庫 - <cstring>
- C++庫 - <cuchar>
- C++庫 - <charconv>
- C++庫 - <cfenv>
- C++庫 - <cmath>
- C++庫 - <ccomplex>
- C++庫 - <expected>
- C++庫 - <format>
- C++庫 - <future>
- C++庫 - <flat_set>
- C++庫 - <flat_map>
- C++庫 - <filesystem>
- C++庫 - <generator>
- C++庫 - <initializer_list>
- C++庫 - <latch>
- C++庫 - <memory_resource>
- C++庫 - <mutex>
- C++庫 - <mdspan>
- C++庫 - <optional>
- C++庫 - <print>
- C++庫 - <ratio>
- C++庫 - <scoped_allocator>
- C++庫 - <semaphore>
- C++庫 - <source_location>
- C++庫 - <span>
- C++庫 - <spanstream>
- C++庫 - <stacktrace>
- C++庫 - <stop_token>
- C++庫 - <syncstream>
- C++庫 - <system_error>
- C++庫 - <string_view>
- C++庫 - <stdatomic>
- C++庫 - <variant>
- C++ STL庫速查表
- C++ STL - 速查表
C++庫 - <unordered_set>
介紹
它是一個關聯容器,以無特定順序儲存唯一元素,並允許根據其值快速檢索單個元素。
定義
以下是std::unordered_set的定義
template < class Key, class Hash = hash<Key>, class Pred = equal_to<Key>, class Alloc = allocator<Key> > class unordered_set;
引數
- 鍵 - 它定義了元素的型別。
- 雜湊 - 它是一個一元函式物件。
- 謂詞 - 它是一個二元謂詞,它接受與元素型別相同的兩個引數並返回一個布林值。
- 分配器 - 它定義了分配器的型別。
成員型別
以下成員型別可用作成員函式的引數或返回型別。
成員型別 | 定義 | 備註 |
---|---|---|
key_type | 它是第一個模板引數 (鍵) | |
value_type | 它是第一個模板引數 (鍵) | 與key_type |
hasher | 它是第二個模板引數 (Hash) | 預設為hash<key_type> |
key_equal | 它是第三個模板引數 (Pred) | 預設為equal_to<key_type> |
allocator_type | 它是第四個模板引數 (Alloc) | 預設為allocator<value_type> |
reference | Alloc::reference | |
const_reference | Alloc::const_reference | |
pointer | Alloc::pointer | 對於預設分配器value_type* |
const_pointer | Alloc::const_pointer | 對於預設分配器const value_type* |
iterator | 一個指向const value_type | 的可轉換const_iterator |
const_iterator | 一個指向const value_type | * |
local_iterator | 一個指向const value_type | 的可轉換const_local_iterator |
const_local_iterator | 一個指向const value_type | * |
size_type | 一個無符號整型 | 通常與size_t相同 |
difference_type | 一個有符號整型 | 通常與ptrdiff_t相同 |
成員函式
以下是成員函式列表
序號 | 方法及描述 |
---|---|
用於賦值內容。 |
容量
迭代器
序號 | 迭代器及描述 |
---|---|
1 |
返回指向開頭的迭代器。 |
2 |
返回指向結尾的迭代器。 |
3 |
返回指向開頭的const_iterator。 |
4 |
返回指向結尾的const_iterator。 |
元素查詢
序號 | 元素查詢及描述 |
---|---|
1 |
用於獲取指向元素的迭代器。 |
2 |
用於計算具有特定鍵的元素個數。 |
3 |
用於獲取具有特定鍵的元素範圍。 |
修改器
序號 | 修改器及描述 |
---|---|
1 |
用於構造和插入元素。 |
2 |
用於使用提示構造和插入元素。 |
3 |
用於插入元素。 |
4 |
用於刪除元素。 |
5 |
用於清除內容。 |
6 |
用於交換內容。 |
桶
序號 | 桶及描述 |
---|---|
1 |
返回桶的數量。 |
2 |
返回最大桶的數量。 |
3 |
返回桶的大小。 |
4 |
查詢元素的桶。 |
雜湊策略
序號 | 雜湊策略及描述 |
---|---|
1 |
返回負載因子。 |
2 |
用於獲取或設定最大負載因子。 |
3 |
用於設定桶的數量。 |
4 |
請求更改桶的容量 |
觀察者
序號 | 觀察者及描述 |
---|---|
1 |
用於獲取雜湊函式。 |
2 |
用於獲取鍵等價謂詞。 |
3 |
用於獲取分配器。 |
非成員過載函式
序號 | 非成員函式過載及描述 |
---|---|
1 | operator== 測試兩個對映是否相等。 |
2 | operator!= 測試兩個對映是否相等。 |
3 |
它交換兩個unordered_set容器的內容。 |
廣告