Chinese (Simplified Han script) (Boost Unordered - en to zh_Hans translation catalogue (296 entries)

en: Class Template unordered_flat_map
zh_Hans: 类模板 unordered++_++flat++_++map

en: `boost::unordered_flat_map` — An open-addressing unordered associative container that associates unique keys with another value.
zh_Hans: `boost::unordered++_++flat++_++map` —— 一种开放寻址的无序关联容器，用于将唯一键与另一个值关联。

en: The performance of `boost::unordered_flat_map` is much better than that of `boost::unordered_map` or other implementations of `std::unordered_map`. Unlike standard unordered associative containers, which are node-based, the elements of a `boost::unordered_flat_map` are held directly in the bucket array, and insertions into an already occupied bucket are diverted to available buckets in the vicinity of the original position. This type of data layout is known as _open addressing_.
zh_Hans: `boost::unordered++_++flat++_++map` 的性能远优于 `boost::unordered++_++map` 或其他 `std::unordered++_++map` 的实现。与基于节点的标准无序关联容器不同， `boost::unordered++_++flat++_++map` 的元素直接存储在桶数组中，且当元素被插入到已被占用的桶时，会将其重定向到原始位置附近的可用桶。这种数据布局类型称为__开放寻址法__。

en: As a result of its using open addressing, the interface of `boost::unordered_flat_map` deviates in a number of aspects from that of `boost::unordered_map`/`std::unordered_map`:
zh_Hans: 由于采用开放寻址法， `boost::unordered++_++flat++_++map` 的接口在多个方面与 `boost::unordered++_++map` / `std::unordered++_++map` 不同：

en: - `value_type` must be move-constructible. - Pointer stability is not kept under rehashing. - `begin()` is not constant-time. - There is no API for bucket handling (except `bucket_count`) or node extraction/insertion. - The maximum load factor of the container is managed internally and can't be set by the user.
zh_Hans: - `value++_++type` 必须支持移动构造。 - 在重哈希的过程中，指针稳定性无法保持。 - `begin()` 不是常数时间复杂度操作。 - 未提供用于桶管理（除 `bucket++_++count` 外）或节点提取/插入的 API。 - 容器的最大负载因子由内部管理，用户无法进行设置。

en: Other than this, `boost::unordered_flat_map` is mostly a drop-in replacement of node-based standard unordered associative containers.
zh_Hans: 除此之外， `boost::unordered++_++flat++_++map` 基本可完全替代基于节点的标准无序关联容器。

en: Synopsis
zh_Hans: 概要

en: Description
zh_Hans: 描述

en: *Template Parameters*
zh_Hans: *模板参数*

en: _Key_
zh_Hans: _键_

en: `std::pair<const Key, T>` must be https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into the container from any `std::pair` object convertible to it, and it also must be https://en.cppreference.com/w/cpp/named_req/Erasable[Erasable^] from the container.
zh_Hans: `std::pair<const key,="" t="">` 必须能从任何可转换为它的 `std::pair` 对象满足对容器的 https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[可原位构造^] 要求，并且还必须满足对容器的 https://en.cppreference.com/w/cpp/named_req/Erasable[可擦除^] 要求。</const>

en: A unary function object type that acts a hash function for a `Key`. It takes a single argument of type `Key` and returns a value of type `std::size_t`.
zh_Hans: 一个一元函数对象类型，用作 `Key` 的哈希函数。它接受一个 `Key` 类型的参数并返回 `std::size_t` 类型的值。

en: A binary function object that induces an equivalence relation on values of type `Key`. It takes two arguments of type `Key` and returns a value of type `bool`.
zh_Hans: 一个二元函数对象，在 `Key` 类型的值上诱导出等价关系。它接受两个 `Key` 类型的参数并返回 `bool` 类型的值。

en: An allocator whose value type is the same as the container's value type.
zh_Hans: 一个分配器，其值类型与容器的值类型相同。

en: Allocators using https://en.cppreference.com/w/cpp/named_req/Allocator#Fancy_pointers[fancy pointers] are supported.
zh_Hans: 支持使用 https://en.cppreference.com/w/cpp/named_req/Allocator#Fancy_pointers[花式指针^] 的分配器。

en: The elements of the container are held into an internal _bucket array_. An element is inserted into a bucket determined by its hash code, but if the bucket is already occupied (a _collision_), an available one in the vicinity of the original position is used.
zh_Hans: 容器的元素存储在内部的__桶数组__中。元素根据其哈希码被插入到对应的桶中，但如果该桶已被占用（即发生__冲突__），则会使用原始位置附近可用的桶。

en: The size of the bucket array can be automatically increased by a call to `insert`/`emplace`, or as a result of calling `rehash`/`reserve`. The _load factor_ of the container (number of elements divided by number of buckets) is never greater than `max_load_factor()`, except possibly for small sizes where the implementation may decide to allow for higher loads.
zh_Hans: 桶数组的大小可通过调用 `insert` / `emplace` 自动增加，也可通过调用 `rehash` / `reserve` 来调整。容器的__负载因子__（元素数量与桶数量的比值）始终不会超过 `max++_++load++_++factor()` ，但在小规模数据情况下，实现可能允许更高的负载因子。

en: If `link:../../../../../container_hash/doc/html/hash.html#ref_hash_is_avalanchinghash[hash_is_avalanching]<Hash>::value` is `true`, the hash function is used as-is; otherwise, a bit-mixing post-processing stage is added to increase the quality of hashing at the expense of extra computational cost.
zh_Hans: 若 link:../../../../../container_hash/doc/html/hash.html#ref_hash_is_avalanchinghash[`hash++_++is++_++avalanching`]`++&lt;++Hash++&gt;++::value` 为 `true` ，则直接使用哈希函数；否则，会添加一个位混合后处理阶段以提高哈希质量，但会牺牲额外的计算成本。

[ctx: :324]
en: ---
zh_Hans: 若 link:../../../../../container_hash/doc/html/hash.html#ref_hash_is_avalanchinghash[`hash++_++is++_++avalanching`]`++&lt;++Hash++&gt;++::value` 为 `true` ，则直接使用哈希函数；否则，会添加一个位混合后处理阶段以提高哈希质量，但会牺牲额外的计算成本。

en: Configuration Macros
zh_Hans: 配置宏

en: `BOOST_UNORDERED_ENABLE_STATS`
zh_Hans: `BOOST++_++UNORDERED++_++ENABLE++_++STATS`

en: Globally define this macro to enable xref:reference/stats.adoc#stats[statistics calculation] for the container. Note that this option decreases the overall performance of many operations.
zh_Hans: 全局定义此宏，以启用容器的 xref:reference/stats.adoc#stats[统计计算] 功能。请注意，此选项会降低许多操作的总体性能。

en: Typedefs
zh_Hans: 类型定义

en: An iterator whose value type is `value_type`.
zh_Hans: 一种迭代器，其值类型为 `value++_++type` 。

[ctx: :344]
en: The iterator category is at least a forward iterator.
zh_Hans: 迭代器类别至少为前向迭代器。

en: Convertible to `const_iterator`.
zh_Hans: 可转换为 `const++_++iterator` 。

en: A constant iterator whose value type is `value_type`.
zh_Hans: 一个常量迭代器，其值类型为 `value++_++type` 。

[ctx: :357]
en: The iterator category is at least a forward iterator.
zh_Hans: 迭代器类别至少为前向迭代器。

en: Constructors
zh_Hans: 构造函数

en: Default Constructor
zh_Hans: 默认构造函数

en: Constructs an empty container using `hasher()` as the hash function, `key_equal()` as the key equality predicate and `allocator_type()` as the allocator.
zh_Hans: 构造一个空容器，使用 `hasher()` 作为哈希函数、 `key++_++equal()` 作为键相等性谓词、以及 `allocator++_++type()` 作为分配器。

[ctx: :370]
en: Postconditions:;; `size() == 0` Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
zh_Hans: 后置条件：`size() == 0` 要求：若使用默认参数，则 `hasher`、`key_equal` 和 `allocator_type` 需满足 https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[可默认构造^] 要求。

en: Bucket Count Constructor
zh_Hans: 桶数构造函数

en: ```c++ explicit unordered_flat_map(size_type n, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); ```
zh_Hans: ```c++ explicit unordered_flat_map(size_type n, const hasher&amp; hf = hasher(), const key_equal&amp; eql = key_equal(), const allocator_type&amp; a = allocator_type()); ```

en: Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate, and `a` as the allocator.
zh_Hans: 构造一个至少包含 `n` 个桶的空容器，使用 `hf` 作为哈希函数、 `eql` 作为键相等性谓词、以及 `a` 作为分配器。

[ctx: :387]
en: Postconditions:;; `size() == 0` Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
zh_Hans: 后置条件：`size() == 0` 要求：若使用默认参数，则 `hasher`、`key_equal` 和 `allocator_type` 需满足 https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[可默认构造^] 要求。

en: Iterator Range Constructor
zh_Hans: 迭代器范围构造函数

en: Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate and `a` as the allocator, and inserts the elements from `[f, l)` into it.
zh_Hans: 构造一个至少包含 `n` 个桶的空容器，使用 `hf` 作为哈希函数、 `eql` 作为键相等性谓词、 `a` 作为分配器，并将区间 `++[++f, l)` 中的元素插入其中。

[ctx: :406]
en: Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
zh_Hans: 要求;; 若使用默认值，则 `hasher` 、 `key++_++equal` 和 `allocator++_++type` 需满足 https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[可默认构造] 要求。

en: Copy Constructor
zh_Hans: 复制构造函数

en: ```c++ unordered_flat_map(unordered_flat_map const& other); ```
zh_Hans: ```c++ unordered_flat_map(unordered_flat_map const&amp; other); ```

en: The copy constructor. Copies the contained elements, hash function, predicate and allocator.
zh_Hans: 复制构造函数。复制所含元素、哈希函数、谓词和分配器。

en: If `Allocator::select_on_container_copy_construction` exists and has the right signature, the allocator will be constructed from its result.
zh_Hans: 若 `Allocator::select++_++on++_++container++_++copy++_++construction` 存在且签名正确，则将根据其结果来构造分配器。

en: Requires:;; `value_type` is copy constructible
zh_Hans: 要求：`value_type` 需满足可复制构造要求。

en: Move Constructor
zh_Hans: 移动构造函数

en: ```c++ unordered_flat_map(unordered_flat_map&& other); ```
zh_Hans: ```c++ unordered_flat_map(unordered_flat_map&amp;&amp; other); ```

en: The move constructor. The internal bucket array of `other` is transferred directly to the new container. The hash function, predicate and allocator are moved-constructed from `other`. If statistics are xref:unordered_flat_map_boost_unordered_enable_stats[enabled], transfers the internal statistical information from `other` and calls `other.reset_stats()`.
zh_Hans: 移动构造函数。`other` 的内部桶数组直接转移到新容器中。哈希函数、谓词和分配器通过移动构造从 `other` 获得。若统计功能已启用（参见 xref:unordered_flat_map_boost_unordered_enable_stats[相关说明]），则转移 `other` 的内部统计信息并调用 `other.reset_stats()`。

en: Iterator Range Constructor with Allocator
zh_Hans: 带分配器的迭代器范围构造函数

en: ```c++ template<class InputIterator> unordered_flat_map(InputIterator f, InputIterator l, const allocator_type& a); ```
zh_Hans: ```c++ template<class inputiterator=""> unordered_flat_map(InputIterator f, InputIterator l, const allocator_type&amp; a); ```</class>

en: Constructs an empty container using `a` as the allocator, with the default hash function and key equality predicate and inserts the elements from `[f, l)` into it.
zh_Hans: 使用 `a` 作为分配器构造一个空容器，使用默认的哈希函数和键相等谓词，并将 `[f, l)` 中的元素插入其中。

[ctx: :445]
en: Requires:;; `hasher`, `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
zh_Hans: 要求：`hasher`、`key_equal` 需满足 https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[可默认构造^] 要求。

en: Allocator Constructor
zh_Hans: 分配器构造函数

en: ```c++ explicit unordered_flat_map(Allocator const& a); ```
zh_Hans: ```c++ explicit unordered_flat_map(Allocator const&amp; a); ```

en: Constructs an empty container, using allocator `a`.
zh_Hans: 使用分配器 a 构造一个空容器。

en: Copy Constructor with Allocator
zh_Hans: 带分配器的复制构造函数

en: ```c++ unordered_flat_map(unordered_flat_map const& other, Allocator const& a); ```
zh_Hans: ```c++ unordered_flat_map(unordered_flat_map const&amp; other, Allocator const&amp; a); ```

en: Constructs a container, copying ``other``'s contained elements, hash function, and predicate, but using allocator `a`.
zh_Hans: 构造一个容器，复制 `other` 所包含的元素、哈希函数和谓词，但使用分配器 `a`。

en: Move Constructor with Allocator
zh_Hans: 带分配器的移动构造函数

en: ```c++ unordered_flat_map(unordered_flat_map&& other, Allocator const& a); ```
zh_Hans: ```c++ unordered_flat_map(unordered_flat_map&amp;&amp; other, Allocator const&amp; a); ```

en: If `a == other.get_allocator()`, the elements of `other` are transferred directly to the new container; otherwise, elements are moved-constructed from those of `other`. The hash function and predicate are moved-constructed from `other`, and the allocator is copy-constructed from `a`. If statistics are xref:unordered_flat_map_boost_unordered_enable_stats[enabled], transfers the internal statistical information from `other` iff `a == other.get_allocator()`, and always calls `other.reset_stats()`.
zh_Hans: 若 `a == other.get_allocator()`，则 `other` 的元素直接转移到新容器中；否则，将通过移动构造从 `other` 的元素创建新元素。哈希函数和谓词通过移动构造从 `other` 获得，分配器则通过复制构造从 `a` 获得。若统计功能已启用（参见 xref:unordered_flat_map_boost_unordered_enable_stats[相关说明]），则仅当 `a == other.get_allocator()` 时转移 `other` 的内部统计信息，且始终会调用 `other.reset_stats()`。

en: Move Constructor from concurrent_flat_map
zh_Hans: 从 concurrent++_++flat++_++map 的移动构造函数

en: ```c++ unordered_flat_map(concurrent_flat_map<Key, T, Hash, Pred, Allocator>&& other); ```
zh_Hans: ```c++ unordered_flat_map(concurrent_flat_map<key, t,="" hash,="" pred,="" allocator="">&amp;&amp; other); ```</key,>

en: Move construction from a xref:#concurrent_flat_map[`concurrent_flat_map`]. The internal bucket array of `other` is transferred directly to the new container. The hash function, predicate and allocator are moved-constructed from `other`. If statistics are xref:unordered_flat_map_boost_unordered_enable_stats[enabled], transfers the internal statistical information from `other` and calls `other.reset_stats()`.
zh_Hans: 从 xref:#concurrent_flat_map[`concurrent_flat_map`][`concurrent++_++flat++_++map`] 移动构造。 `other` 的内部桶数组直接转移至新容器。哈希函数、谓词和分配器均从 `other` 移动构造。若统计功能 xref:#unordered_flat_map_boost_unordered_enable_stats[已启用] ，则转移 `other` 的内部统计信息，并调用 `other.reset++_++stats()` 。

en: Complexity:;; Constant time. Concurrency:;; Blocking on `other`.
zh_Hans: 复杂度：常数时间。并发：阻塞 `other`。

en: Initializer List Constructor
zh_Hans: 初始化列表构造函数

en: Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `eql` as the key equality predicate and `a`, and inserts the elements from `il` into it.
zh_Hans: 构造一个至少包含 `n` 个桶的空容器，使用 `hf` 作为哈希函数、 `eql` 作为键相等性谓词、以及 `a` 作为分配器，并将 `il` 中的元素插入其中。

[ctx: :512]
en: Requires:;; If the defaults are used, `hasher`, `key_equal` and `allocator_type` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
zh_Hans: 要求;; 若使用默认值，则 `hasher` 、 `key++_++equal` 和 `allocator++_++type` 需满足 https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[可默认构造] 要求。

en: Bucket Count Constructor with Allocator
zh_Hans: 带分配器的桶数构造函数

en: ```c++ unordered_flat_map(size_type n, allocator_type const& a); ```
zh_Hans: ```c++ unordered_flat_map(size_type n, allocator_type const&amp; a); ```

en: Constructs an empty container with at least `n` buckets, using `hf` as the hash function, the default hash function and key equality predicate and `a` as the allocator.
zh_Hans: 构造一个至少包含 `n` 个桶的空容器，使用 `hf` 作为哈希函数，使用默认的键相等谓词，以及 `a` 作为分配器。

en: Postconditions:;; `size() == 0` Requires:;; `hasher` and `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
zh_Hans: 后置条件：`size() == 0` 要求：`hasher` 和 `key_equal` 需满足 https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[可默认构造^] 要求。

en: Bucket Count Constructor with Hasher and Allocator
zh_Hans: 带哈希函数和分配器的桶数构造函数

en: ```c++ unordered_flat_map(size_type n, hasher const& hf, allocator_type const& a); ```
zh_Hans: ```c++ unordered_flat_map(size_type n, hasher const&amp; hf, allocator_type const&amp; a); ```

en: Constructs an empty container with at least `n` buckets, using `hf` as the hash function, the default key equality predicate and `a` as the allocator.
zh_Hans: unordered_flat_map(size_type n, hasher const&amp; hf, allocator_type const&amp; a);

en: Postconditions:;; `size() == 0` Requires:;; `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
zh_Hans: 后置条件：`size() == 0` 要求：`key_equal` 需满足 https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[可默认构造^] 要求。

en: Iterator Range Constructor with Bucket Count and Allocator
zh_Hans: 带桶数和分配器的迭代器范围构造函数

en: Constructs an empty container with at least `n` buckets, using `a` as the allocator and default hash function and key equality predicate, and inserts the elements from `[f, l)` into it.
zh_Hans: 构造一个至少包含 `n` 个桶的空容器，使用 `a` 作为分配器、以及默认的哈希函数和键相等性谓词，并将 `++[++f, l)` 范围内的元素插入其中。

[ctx: :552]
en: Requires:;; `hasher`, `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
zh_Hans: 要求;; `hasher` 和 `key++_++equal` 需满足 https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[可默认构造] 要求。

en: Iterator Range Constructor with Bucket Count and Hasher
zh_Hans: 带桶数和哈希函数的迭代器范围构造函数

en: Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `a` as the allocator, with the default key equality predicate, and inserts the elements from `[f, l)` into it.
zh_Hans: 构造一个至少包含 `n` 个桶的空容器，使用 `hf` 作为哈希函数、 `a` 作为分配器以及默认的键相等性谓词，并将 `++[++f, l)` 范围内的元素插入其中。

[ctx: :567]
en: Requires:;; `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
zh_Hans: 要求;; `key++_++equal` 需满足 https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[可默认构造] 要求。

en: initializer_list Constructor with Allocator
zh_Hans: 带分配器的初始化列表构造函数

en: ```c++ unordered_flat_map(std::initializer_list<value_type> il, const allocator_type& a); ```
zh_Hans: ```c++ unordered_flat_map(std::initializer_list<value_type> il, const allocator_type&amp; a); ```</value_type>

en: Constructs an empty container using `a` and default hash function and key equality predicate, and inserts the elements from `il` into it.
zh_Hans: 构造一个空容器，使用 `a` 作为分配器、以及默认的哈希函数和键相等性谓词，并将 `il` 中的元素插入其中。

[ctx: :580]
en: Requires:;; `hasher` and `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
zh_Hans: 要求：`hasher` 和 `key_equal` 需满足 https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[可默认构造^] 要求。

en: initializer_list Constructor with Bucket Count and Allocator
zh_Hans: 带桶数和分配器的初始化列表构造函数

en: ```c++ unordered_flat_map(std::initializer_list<value_type> il, size_type n, const allocator_type& a); ```
zh_Hans: ```c++ unordered_flat_map(std::initializer_list<value_type> il, size_type n, const allocator_type&amp; a); ```</value_type>

en: Constructs an empty container with at least `n` buckets, using `a` and default hash function and key equality predicate, and inserts the elements from `il` into it.
zh_Hans: 构造一个至少包含 `n` 个桶的空容器，使用 `a` 作为分配器以及默认的哈希函数和键相等谓词，并将 `il` 中的元素插入其中。

[ctx: :593]
en: Requires:;; `hasher` and `key_equal` need to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
zh_Hans: 要求：`hasher` 和 `key_equal` 需满足 https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[可默认构造^] 要求。

en: initializer_list Constructor with Bucket Count and Hasher and Allocator
zh_Hans: 带桶数、哈希函数和分配器的初始化列表构造函数

en: ```c++ unordered_flat_map(std::initializer_list<value_type> il, size_type n, const hasher& hf, const allocator_type& a); ```
zh_Hans: ```c++ unordered_flat_map(std::initializer_list<value_type> il, size_type n, const hasher&amp; hf, const allocator_type&amp; a); ```</value_type>

en: Constructs an empty container with at least `n` buckets, using `hf` as the hash function, `a` as the allocator and default key equality predicate,and inserts the elements from `il` into it.
zh_Hans: 构造一个至少包含 `n` 个桶的空容器，使用 `hf` 作为哈希函数、`a` 作为分配器以及默认的键相等谓词，并将 `il` 中的元素插入其中。

[ctx: :607]
en: Requires:;; `key_equal` needs to be https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^].
zh_Hans: 要求：`key_equal` 需满足 https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[可默认构造^] 要求。

en: Destructor
zh_Hans: 析构函数

en: Note:;; The destructor is applied to every element, and all memory is deallocated
zh_Hans: 注意：析构函数会应用于每个元素，并且所有内存都会被释放。

en: Assignment
zh_Hans: 赋值操作

en: Copy Assignment
zh_Hans: 复制赋值

en: ```c++ unordered_flat_map& operator=(unordered_flat_map const& other); ```
zh_Hans: ```c++ unordered_flat_map&amp; operator=(unordered_flat_map const&amp; other); ```

en: The assignment operator. Destroys previously existing elements, copy-assigns the hash function and predicate from `other`, copy-assigns the allocator from `other` if `Alloc::propagate_on_container_copy_assignment` exists and `Alloc::propagate_on_container_copy_assignment::value` is `true`, and finally inserts copies of the elements of `other`.
zh_Hans: 赋值操作符。该操作会销毁容器中原有的元素，并从 other 复制赋值哈希函数与键相等性谓词。若 Alloc::propagate_on_container_copy_assignment 存在，且 Alloc::propagate_on_container_copy_assignment::value 为 true，则从 other 复制赋值分配器，最后插入 other 中所有元素的副本。

[ctx: :635]
en: Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]
zh_Hans: 要求：`value_type` 需满足 https://en.cppreference.com/w/cpp/named_req/CopyInsertable[可复制插入^] 要求。

en: Move Assignment
zh_Hans: 移动赋值

en: ```c++ unordered_flat_map& operator=(unordered_flat_map&& other) noexcept((boost::allocator_traits<Allocator>::is_always_equal::value || boost::allocator_traits<Allocator>::propagate_on_container_move_assignment::value) && std::is_same<pointer, value_type*>::value); ``` The move assignment operator. Destroys previously existing elements, swaps the hash function and predicate from `other`, and move-assigns the allocator from `other` if `Alloc::propagate_on_container_move_assignment` exists and `Alloc::propagate_on_container_move_assignment::value` is `true`. If at this point the allocator is equal to `other.get_allocator()`, the internal bucket array of `other` is transferred directly to the new container; otherwise, inserts move-constructed copies of the elements of `other`. If statistics are xref:unordered_flat_map_boost_unordered_enable_stats[enabled], transfers the internal statistical information from `other` iff the final allocator is equal to `other.get_allocator()`, and always calls `other.reset_stats()`.
zh_Hans: ```c++ unordered_flat_map&amp; operator=(unordered_flat_map&amp;&amp; other) noexcept((boost::allocator_traits<allocator>::is_always_equal::value || boost::allocator_traits<allocator>::propagate_on_container_move_assignment::value) &amp;&amp; std::is_same<pointer, value_type*="">::value); ``` 移动赋值运算符。销毁之前存在的元素，交换 other 中的哈希函数和谓词，若 Alloc::propagate_on_container_move_assignment 存在且 Alloc::propagate_on_container_move_assignment::value 为 true，则从 other 移动赋值分配器。若此时分配器与 other.get_allocator() 相等，则将 other 的内部桶数组直接转移至当前容器；否则，插入通过移动构造从 other 元素创建的副本。若统计功能已启用（参见 xref:unordered_flat_map_boost_unordered_enable_stats[相关说明]），则仅当最终分配器与 other.get_allocator() 相等时转移 other 的内部统计信息，且始终会调用 other.reset_stats()。</pointer,></allocator></allocator>

en: Initializer List Assignment
zh_Hans: 初始化列表赋值

en: ```c++ unordered_flat_map& operator=(std::initializer_list<value_type> il); ```
zh_Hans: ```c++ unordered_flat_map&amp; operator=(std::initializer_list<value_type> il); ```</value_type>

en: Assign from values in initializer list. All previously existing elements are destroyed.
zh_Hans: 从初始化列表中的值进行赋值。所有之前存在的元素均被销毁。

[ctx: :664]
en: Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]
zh_Hans: 要求：`value_type` 需满足 https://en.cppreference.com/w/cpp/named_req/CopyInsertable[可复制插入^] 要求。

en: Iterators
zh_Hans: 迭代器

en: Returns:;; An iterator referring to the first element of the container, or if the container is empty the past-the-end value for the container. Complexity:;; O(`bucket_count()`)
zh_Hans: 返回：指向容器第一个元素的迭代器，若容器为空则返回容器尾后迭代器。复杂度：O(`bucket_count()`)

en: Returns:;; An iterator which refers to the past-the-end value for the container.
zh_Hans: 返回：指向容器尾后位置的迭代器。

en: Returns:;; A `const_iterator` referring to the first element of the container, or if the container is empty the past-the-end value for the container. Complexity:;; O(`bucket_count()`)
zh_Hans: 返回：指向容器第一个元素的 `const_iterator`，若容器为空，则返回容器尾后迭代器。复杂度：O(`bucket_count()`)

en: Returns:;; A `const_iterator` which refers to the past-the-end value for the container.
zh_Hans: 返回：指向容器尾后位置的 `const_iterator`。

en: Size and Capacity
zh_Hans: 大小与容量

en: empty
zh_Hans: 空

en: Returns:;; `size() == 0`
zh_Hans: 返回: `size() == 0`

en: size
zh_Hans: 大小

en: Returns:;; `std::distance(begin(), end())`
zh_Hans: 返回：`std::distance(begin(), end())`

en: max_size
zh_Hans: max++_++size

en: Returns:;; `size()` of the largest possible container.
zh_Hans: 返回：可能的最大容器的 `size()`。

en: Modifiers
zh_Hans: 修改器

en: emplace
zh_Hans: 原地构造

en: ```c++ template<class... Args> std::pair<iterator, bool> emplace(Args&&... args); ```
zh_Hans: ```c++ template<class... args=""> std::pair<iterator, bool=""> emplace(Args&amp;&amp;... args); ```</iterator,></class...>

[ctx: :754]
en: Inserts an object, constructed with the arguments `args`, in the container if and only if there is no element in the container with an equivalent key.
zh_Hans: 当且仅当容器中没有等价的键时，插入一个使用参数 `args` 构造的对象。

[ctx: :757]
en: Requires:;; `value_type` is constructible from `args`. Returns:;; The `bool` component of the return type is `true` if an insert took place. + + If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators, pointers and references, but only if the insert causes the load to be greater than the maximum load. + + If `args...` is of the form `k,v`, it delays constructing the whole object until it is certain that an element should be inserted, using only the `k` argument to check.
zh_Hans: 要求：`value_type` 可从 `args` 构造。返回：若执行了插入，则返回类型中的 `bool` 分量为 `true`。+ +若执行了插入，则迭代器指向新插入的元素；否则指向等价的元素。抛出：若调用 `hasher` 以外的操作抛出异常，则函数无效果。注意：可能使迭代器、指针和引用失效，但仅当插入导致负载大于最大负载时才会发生。+ +若 `args...` 的形式为 `k,v`，则仅在确定应插入元素时才构造整个对象，检查时仅使用 `k` 参数。

en: emplace_hint
zh_Hans: emplace++_++hint

en: ```c++ template<class... Args> iterator emplace_hint(const_iterator position, Args&&... args); ```
zh_Hans: ```c++ template<class... args=""> iterator emplace_hint(const_iterator position, Args&amp;&amp;... args); ```</class...>

[ctx: :773]
en: Inserts an object, constructed with the arguments `args`, in the container if and only if there is no element in the container with an equivalent key.
zh_Hans: 当且仅当容器中没有等价的键时，插入一个使用参数 `args` 构造的对象。

en: `position` is a suggestion to where the element should be inserted. This implementation ignores it.
zh_Hans: `position` 是一个关于元素应插入位置的建议。此实现会忽略该建议。

[ctx: :778]
en: Requires:;; `value_type` is constructible from `args`. Returns:;; The `bool` component of the return type is `true` if an insert took place. + + If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators, pointers and references, but only if the insert causes the load to be greater than the maximum load. + + If `args...` is of the form `k,v`, it delays constructing the whole object until it is certain that an element should be inserted, using only the `k` argument to check.
zh_Hans: 要求：`value_type` 可从 `args` 构造。返回：若执行了插入，则返回类型中的 `bool` 分量为 `true`。+ +若执行了插入，则迭代器指向新插入的元素；否则指向等价的元素。抛出：若调用 `hasher` 以外的操作抛出异常，则函数无效果。注意：可能使迭代器、指针和引用失效，但仅当插入导致负载大于最大负载时才会发生。+ +若 `args...` 的形式为 `k,v`，则仅在确定应插入元素时才构造整个对象，检查时仅使用 `k` 参数。

en: Copy Insert
zh_Hans: 复制插入

en: ```c++ std::pair<iterator, bool> insert(const value_type& obj); std::pair<iterator, bool> insert(const init_type& obj); ```
zh_Hans: ```c++ std::pair<iterator, bool=""> insert(const value_type&amp; obj); std::pair<iterator, bool=""> insert(const init_type&amp; obj); ```</iterator,></iterator,>

[ctx: :795]
en: Inserts `obj` in the container if and only if there is no element in the container with an equivalent key.
zh_Hans: 当且仅当容器中没有等价的键时，将 `obj` 插入容器。

en: Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. Returns:;; The `bool` component of the return type is `true` if an insert took place. + + If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators, pointers and references, but only if the insert causes the load to be greater than the maximum load. + + A call of the form `insert(x)`, where `x` is equally convertible to both `const value_type&` and `const init_type&`, is not ambiguous and selects the `init_type` overload.
zh_Hans: 要求：`value_type` 需满足 https://en.cppreference.com/w/cpp/named_req/CopyInsertable[可复制插入^] 要求。返回：若执行了插入，则返回类型中的 `bool` 分量为 `true`。+ +若执行了插入，则迭代器指向新插入的元素；否则指向等价的元素。抛出：若调用 `hasher` 以外的操作抛出异常，则函数无效果。注意：可能使迭代器、指针和引用失效，但仅当插入导致负载大于最大负载时才会发生。+ +形式为 `insert(x)` 的调用（其中 `x` 可同等转换为 `const value_type&amp;` 和 `const init_type&amp;`）不会产生歧义，并且会选择 `init_type` 重载。

en: Move Insert
zh_Hans: 移动插入

en: ```c++ std::pair<iterator, bool> insert(value_type&& obj); std::pair<iterator, bool> insert(init_type&& obj); ```
zh_Hans: ```c++ std::pair<iterator, bool=""> insert(value_type&amp;&amp; obj); std::pair<iterator, bool=""> insert(init_type&amp;&amp; obj); ```</iterator,></iterator,>

[ctx: :815]
en: Inserts `obj` in the container if and only if there is no element in the container with an equivalent key.
zh_Hans: 当且仅当容器中没有等价的键时，将 `obj` 插入容器。

en: Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. Returns:;; The `bool` component of the return type is `true` if an insert took place. + + If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators, pointers and references, but only if the insert causes the load to be greater than the maximum load. + + A call of the form `insert(x)`, where `x` is equally convertible to both `value_type&&` and `init_type&&`, is not ambiguous and selects the `init_type` overload.
zh_Hans: 要求：`value_type` 需满足 https://en.cppreference.com/w/cpp/named_req/MoveInsertable[可移动插入^] 要求。返回：若执行了插入，则返回类型中的 `bool` 分量为 `true`。+ +若执行了插入，则迭代器指向新插入的元素；否则指向等价的元素。抛出：若调用 `hasher` 以外的操作抛出异常，则函数无效果。注意：可能使迭代器、指针和引用失效，但仅当插入导致负载大于最大负载时才会发生。+ +形式为 `insert(x)` 的调用（其中 `x` 可同等转换为 `value_type&amp;&amp;` 和 `init_type&amp;&amp;`）不会产生歧义，并且会选择 `init_type` 重载。

en: Copy Insert with Hint
zh_Hans: 带提示的复制插入

en: ```c++ iterator insert(const_iterator hint, const value_type& obj); iterator insert(const_iterator hint, const init_type& obj); ``` Inserts `obj` in the container if and only if there is no element in the container with an equivalent key.
zh_Hans: `iterator insert(const_iterator hint, const value_type&amp; obj); iterator insert(const_iterator hint, const init_type&amp; obj);` 当且仅当容器中没有等价的键时，将 `obj` 插入容器。

[ctx: :836]
en: `hint` is a suggestion to where the element should be inserted. This implementation ignores it.
zh_Hans: `hint` 是一个关于元素插入位置的提示，本实现将忽略该提示。

en: Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^]. Returns:;; The `bool` component of the return type is `true` if an insert took place. + + If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators, pointers and references, but only if the insert causes the load to be greater than the maximum load. + + A call of the form `insert(hint, x)`, where `x` is equally convertible to both `const value_type&` and `const init_type&`, is not ambiguous and selects the `init_type` overload.
zh_Hans: 要求：`value_type` 需满足 https://en.cppreference.com/w/cpp/named_req/CopyInsertable[可复制插入^] 要求。返回：若执行了插入，则返回类型中的 `bool` 分量为 `true`。+ +若执行了插入，则迭代器指向新插入的元素；否则指向等价的元素。抛出：若调用 `hasher` 以外的操作抛出异常，则函数无效果。注意：可能使迭代器、指针和引用失效，但仅当插入导致负载大于最大负载时才会发生。+ +形式为 `insert(hint, x)` 的调用（其中 `x` 可同等转换为 `const value_type&amp;` 和 `const init_type&amp;`）不会产生歧义，并且会选择 `init_type` 重载。

en: Move Insert with Hint
zh_Hans: 带提示的移动插入

en: ```c++ iterator insert(const_iterator hint, value_type&& obj); iterator insert(const_iterator hint, init_type&& obj); ```
zh_Hans: ```c++ iterator insert(const_iterator hint, value_type&amp;&amp; obj); iterator insert(const_iterator hint, init_type&amp;&amp; obj); ```

[ctx: :856]
en: Inserts `obj` in the container if and only if there is no element in the container with an equivalent key.
zh_Hans: 当且仅当容器中不存在等价键时，将 `obj` 对象插入到容器中。

[ctx: :858]
en: `hint` is a suggestion to where the element should be inserted. This implementation ignores it.
zh_Hans: `hint` 是一个关于元素应插入位置的建议。此实现会忽略该建议。

en: Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/MoveInsertable[MoveInsertable^]. Returns:;; The `bool` component of the return type is `true` if an insert took place. + + If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators, pointers and references, but only if the insert causes the load to be greater than the maximum load. + + A call of the form `insert(hint, x)`, where `x` is equally convertible to both `value_type&&` and `init_type&&`, is not ambiguous and selects the `init_type` overload.
zh_Hans: 要求：`value_type` 需满足 https://en.cppreference.com/w/cpp/named_req/MoveInsertable[可移动插入^] 要求。返回：若执行了插入，则返回类型中的 `bool` 分量为 `true`。+ +若执行了插入，则迭代器指向新插入的元素；否则指向等价的元素。抛出：若调用 `hasher` 以外的操作抛出异常，则函数无效果。注意：可能使迭代器、指针和引用失效，但仅当插入导致负载大于最大负载时才会发生。+ +形式为 `insert(hint, x)` 的调用（其中 `x` 可同等转换为 `value_type&amp;&amp;` 和 `init_type&amp;&amp;`）不会产生歧义，并且会选择 `init_type` 重载。

en: Insert Iterator Range
zh_Hans: 迭代器范围插入

en: ```c++ template<class InputIterator> void insert(InputIterator first, InputIterator last); ```
zh_Hans: ```c++ template<class inputiterator=""> void insert(InputIterator first, InputIterator last); ```</class>

[ctx: :877]
en: Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key.
zh_Hans: 将元素范围插入容器中。仅当容器中不存在等价键的元素时，才会插入相应元素。

en: Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[EmplaceConstructible^] into the container from `*first`. Throws:;; When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators, pointers and references, but only if the insert causes the load to be greater than the maximum load.
zh_Hans: 要求：`value_type` 需从 `*first` 处满足对容器的 https://en.cppreference.com/w/cpp/named_req/EmplaceConstructible[可原位构造^] 要求。抛出：当插入单个元素时，若调用 `hasher` 以外的操作抛出异常，则函数无效果。注意：可能使迭代器、指针和引用失效，但仅当插入导致负载大于最大负载时才会发生。

en: Insert Initializer List
zh_Hans: 初始化列表插入

en: ```c++ void insert(std::initializer_list<value_type>); ```
zh_Hans: ```c++ void insert(std::initializer_list<value_type>); ```</value_type>

[ctx: :891]
en: Inserts a range of elements into the container. Elements are inserted if and only if there is no element in the container with an equivalent key.
zh_Hans: 将范围内的元素插入容器中。当且仅当容器中没有等价的键时，才会插入元素。

en: Requires:;; `value_type` is https://en.cppreference.com/w/cpp/named_req/CopyInsertable[CopyInsertable^] into the container. Throws:;; When inserting a single element, if an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators, pointers and references, but only if the insert causes the load to be greater than the maximum load.
zh_Hans: 要求：`value_type` 需满足对容器而言的 https://en.cppreference.com/w/cpp/named_req/CopyInsertable[可复制插入^] 要求。抛出：当插入单个元素时，若调用 `hasher` 以外的操作抛出异常，则函数无效果。注意：可能使迭代器、指针和引用失效，但仅当插入导致负载大于最大负载时才会发生。

en: try_emplace
zh_Hans: try++_++emplace

en: ```c++ template<class... Args> std::pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); template<class... Args> std::pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); template<class K, class... Args> std::pair<iterator, bool> try_emplace(K&& k, Args&&... args); ```
zh_Hans: ```c++ template<class... args=""> std::pair<iterator, bool=""> try_emplace(const key_type&amp; k, Args&amp;&amp;... args); template<class... args=""> std::pair<iterator, bool=""> try_emplace(key_type&amp;&amp; k, Args&amp;&amp;... args); template<class k,="" class...="" args=""> std::pair<iterator, bool=""> try_emplace(K&amp;&amp; k, Args&amp;&amp;... args); ```</iterator,></class></iterator,></class...></iterator,></class...>

[ctx: :910]
en: Inserts a new element into the container if there is no existing element with key `k` contained within it.
zh_Hans: 如果容器中不存在键为 `k` 的元素，则向容器中插入一个新元素。

[ctx: :912]
en: If there is an existing element with key `k` this function does nothing.
zh_Hans: 若容器中不存在键为 `k` 的元素，则插入一个新元素。

en: Returns:;; The `bool` component of the return type is `true` if an insert took place. + + If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; This function is similiar to xref:#unordered_flat_map_emplace[emplace], with the difference that no `value_type` is constructed if there is an element with an equivalent key; otherwise, the construction is of the form: + + -- ```c++
zh_Hans: 返回：若执行了插入，则返回类型中的 `bool` 分量为 `true`。+ +若执行了插入，则迭代器指向新插入的元素；否则指向等价的元素。抛出：若调用 `hasher` 以外的操作抛出异常，则函数无效果。注意：此函数与 xref:#unordered_flat_map_emplace[emplace] 类似，区别在于：若存在等价的键，则不构造 `value_type`；否则，构造形式如下：+ + -- `c++`

[ctx: :925]
en: value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<Key>(k)), std::forward_as_tuple(std::forward<Args>(args)...))
zh_Hans: value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<key>(k)), std::forward_as_tuple(std::forward<args>(args)...))</args></key>

[ctx: :930]
en: value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<K>(k)), std::forward_as_tuple(std::forward<Args>(args)...)) ```
zh_Hans: value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<k>(k)), std::forward_as_tuple(std::forward<args>(args)...)) ```</args></k>

en: unlike xref:#unordered_flat_map_emplace[emplace], which simply forwards all arguments to ``value_type``'s constructor.
zh_Hans: 与 xref:#unordered_flat_map_emplace[emplace] 不同，后者只是将所有参数转发给 `value_type` 的构造函数。

[ctx: :937]
en: Can invalidate iterators pointers and references, but only if the insert causes the load to be greater than the maximum load.
zh_Hans: 可能会导致迭代器、指针和引用失效，但仅当插入操作导致负载因子超过最大负载因子时才会发生。

[ctx: :939]
en: The `template<class K, class\... Args>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
zh_Hans: `template<class k,="" args="">` 重载仅在以下条件下参与重载决议：`Hash::is_transparent` 和 `Pred::is_transparent` 是有效的成员 typedef，且 `iterator` 和 `const_iterator` 均不能从 `K` 隐式转换。库假定 `Hash` 可同时以 `K` 和 `Key` 调用，且 `Pred` 是透明的。这实现了异构查找，从而避免实例化 `Key` 类型对象的开销。</class>

en: try_emplace with Hint
zh_Hans: 带提示的 try++_++emplace

en: ```c++ template<class... Args> iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); template<class... Args> iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); template<class K, class... Args> iterator try_emplace(const_iterator hint, K&& k, Args&&... args); ```
zh_Hans: ```c++ template<class... args=""> iterator try_emplace(const_iterator hint, const key_type&amp; k, Args&amp;&amp;... args); template<class... args=""> iterator try_emplace(const_iterator hint, key_type&amp;&amp; k, Args&amp;&amp;... args); template<class k,="" class...="" args=""> iterator try_emplace(const_iterator hint, K&amp;&amp; k, Args&amp;&amp;... args); ```</class></class...></class...>

[ctx: :955]
en: Inserts a new element into the container if there is no existing element with key `k` contained within it.
zh_Hans: 如果容器中不存在键为 `k` 的元素，则向容器中插入一个新元素。

[ctx: :957]
en: If there is an existing element with key `k` this function does nothing.
zh_Hans: 如果存在键为 `k` 的元素，则该函数不执行任何操作。

en: `hint` is a suggestion to where the element should be inserted.  This implementation ignores it.
zh_Hans: `hint` 是一个关于元素应插入位置的建议。此实现会忽略该建议。

en: Returns:;; If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; This function is similiar to xref:#unordered_flat_map_emplace_hint[emplace_hint], with the difference that no `value_type` is constructed if there is an element with an equivalent key; otherwise, the construction is of the form: + + -- ```c++
zh_Hans: 返回：若执行了插入，则迭代器指向新插入的元素；否则指向等价的元素。抛出：若调用 `hasher` 以外的操作抛出异常，则函数无效果。注意：此函数与 xref:#unordered_flat_map_emplace_hint[emplace_hint] 类似，区别在于：若存在等价的键，则不构造 `value_type`；否则，构造形式如下：+ + -- `c++`

[ctx: :970]
en: value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<Key>(k)), std::forward_as_tuple(std::forward<Args>(args)...))
zh_Hans: value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<key>(k)), std::forward_as_tuple(std::forward<args>(args)...))</args></key>

[ctx: :975]
en: value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<K>(k)), std::forward_as_tuple(std::forward<Args>(args)...)) ```
zh_Hans: value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<k>(k)), std::forward_as_tuple(std::forward<args>(args)...)) ```</args></k>

en: unlike xref:#unordered_flat_map_emplace_hint[emplace_hint], which simply forwards all arguments to ``value_type``'s constructor.
zh_Hans: 而非像 xref:#unordered_flat_map_emplace_hint[emplace_hint] 只是简单地将所有参数转发给 value_type 的构造函数。

[ctx: :982]
en: Can invalidate iterators pointers and references, but only if the insert causes the load to be greater than the maximum load.
zh_Hans: 可能会导致迭代器、指针和引用失效，但仅当插入操作导致负载因子超过最大负载因子时才会发生。

[ctx: :984]
en: The `template<class K, class\... Args>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
zh_Hans: `template<class k,="" args="">` 重载仅在以下条件下参与重载决议：`Hash::is_transparent` 和 `Pred::is_transparent` 是有效的成员 typedef，且 `iterator` 和 `const_iterator` 均不能从 `K` 隐式转换。库假定 `Hash` 可同时以 `K` 和 `Key` 调用，且 `Pred` 是透明的。这提供了异构查找能力，从而避免构造 `Key` 类型实例的开销。</class>

en: insert_or_assign
zh_Hans: insert++_++or++_++assign

en: ```c++ template<class M> std::pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); template<class M> std::pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); template<class K, class M> std::pair<iterator, bool> insert_or_assign(K&& k, M&& obj); ```
zh_Hans: ```c++ template<class m=""> std::pair<iterator, bool=""> insert_or_assign(const key_type&amp; k, M&amp;&amp; obj); template<class m=""> std::pair<iterator, bool=""> insert_or_assign(key_type&amp;&amp; k, M&amp;&amp; obj); template<class k,="" class="" m=""> std::pair<iterator, bool=""> insert_or_assign(K&amp;&amp; k, M&amp;&amp; obj); ```</iterator,></class></iterator,></class></iterator,></class>

[ctx: :1000]
en: Inserts a new element into the container or updates an existing one by assigning to the contained value.
zh_Hans: 向容器中插入一个新元素，或通过赋值给已包含的值来更新现有元素。

[ctx: :1002]
en: If there is an element with key `k`, then it is updated by assigning `std::forward<M>(obj)`.
zh_Hans: 如果存在键为 k 的元素，则通过赋值 std::forward<m>(obj) 来更新该元素</m>

[ctx: :1004]
en: If there is no such element, it is added to the container as: ```c++
zh_Hans: 如果不存在这样的元素，则将其添加到容器中，形式如下：```c++

[ctx: :1007]
en: value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<Key>(k)), std::forward_as_tuple(std::forward<M>(obj)))
zh_Hans: value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<key>(k)), std::forward_as_tuple(std::forward<m>(obj)))</m></key>

[ctx: :1012]
en: value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<K>(k)), std::forward_as_tuple(std::forward<M>(obj))) ```
zh_Hans: value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<k>(k)), std::forward_as_tuple(std::forward<m>(obj))) ```</m></k>

en: Returns:;; The `bool` component of the return type is `true` if an insert took place. + + If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators pointers and references, but only if the insert causes the load to be greater than the maximum load.  + + The `template<class K, class M>` only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
zh_Hans: 返回：若执行了插入，则返回类型中的 `bool` 分量为 `true`。+ +若执行了插入，则迭代器指向新插入的元素；否则指向等价的元素。抛出：若调用 `hasher` 以外的操作抛出异常，则函数无效果。注意：可能会导致迭代器、指针和引用失效，但仅当插入操作导致负载因子超过最大负载因子时才会发生。+ +`template<class k,="" class="" m="">` 仅在 `Hash::is_transparent` 和 `Pred::is_transparent` 是有效的成员 typedef 时参与重载决议。库假定 `Hash` 可同时以 `K` 和 `Key` 调用，且 `Pred` 是透明的。这提供了异构查找能力，从而避免构造 `Key` 类型实例的开销。</class>

en: insert_or_assign with Hint
zh_Hans: 带提示的 insert++_++or++_++assign

en: ```c++ template<class M> iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); template<class M> iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); template<class K, class M> iterator insert_or_assign(const_iterator hint, K&& k, M&& obj); ```
zh_Hans: ```c++ template<class m=""> iterator insert_or_assign(const_iterator hint, const key_type&amp; k, M&amp;&amp; obj); template<class m=""> iterator insert_or_assign(const_iterator hint, key_type&amp;&amp; k, M&amp;&amp; obj); template<class k,="" class="" m=""> iterator insert_or_assign(const_iterator hint, K&amp;&amp; k, M&amp;&amp; obj); ```</class></class></class>

[ctx: :1038]
en: Inserts a new element into the container or updates an existing one by assigning to the contained value.
zh_Hans: 向容器中插入一个新元素，或通过赋值给已存在的值来更新现有元素。

[ctx: :1040]
en: If there is an element with key `k`, then it is updated by assigning `std::forward<M>(obj)`.
zh_Hans: 如果存在键为 `k` 的元素，则通过赋值 `std::forward<m>(obj)` 来更新该元素。</m>

[ctx: :1042]
en: If there is no such element, it is added to the container as: ```c++
zh_Hans: 如果不存在这样的元素，则将其添加到容器中，形式如下：```c++

[ctx: :1045]
en: value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<Key>(k)), std::forward_as_tuple(std::forward<M>(obj)))
zh_Hans: value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<key>(k)), std::forward_as_tuple(std::forward<m>(obj)))</m></key>

[ctx: :1050]
en: value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<K>(k)), std::forward_as_tuple(std::forward<M>(obj))) ```
zh_Hans: value_type(std::piecewise_construct, std::forward_as_tuple(std::forward<k>(k)), std::forward_as_tuple(std::forward<m>(obj))) ```</m></k>

[ctx: :1055]
en: `hint` is a suggestion to where the element should be inserted. This implementation ignores it.
zh_Hans: `hint` 是一个关于元素应插入位置的建议。此实现会忽略该建议。

en: Returns:;; If an insert took place, then the iterator points to the newly inserted element. Otherwise, it points to the element with equivalent key. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators, pointers and references, but only if the insert causes the load to be greater than the maximum load. + + The `template<class K, class M>` only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
zh_Hans: 返回：若执行了插入，则迭代器指向新插入的元素；否则指向等价的元素。抛出：若调用 `hasher` 以外的操作抛出异常，则函数无效果。注意：可能会导致迭代器、指针和引用失效，但仅当插入操作导致负载因子超过最大负载因子时才会发生。+ +`template<class k,="" class="" m="">` 仅在 `Hash::is_transparent` 和 `Pred::is_transparent` 是有效的成员 typedef 时参与重载决议。库假定 `Hash` 可同时以 `K` 和 `Key` 调用，且 `Pred` 是透明的。这提供了异构查找能力，从而避免构造 `Key` 类型实例的开销。</class>

en: Erase by Position
zh_Hans: 通过位置擦除

en: Erase the element pointed to by `position`.
zh_Hans: 擦除由 `position` 指向的元素。

en: Returns:;; An opaque object implicitly convertible to the `iterator` or `const_iterator` immediately following `position` prior to the erasure. Throws:;; Nothing. Notes:;; The opaque object returned must only be discarded or immediately converted to `iterator` or `const_iterator`.
zh_Hans: 返回;; 返回一个不透明对象，该对象可隐式转换为擦除前紧接在 `position` 之后的 `iterator` 或 `const++_++iterator` 。 抛出;; 无。 注意;; 返回的不透明对象必须被立即丢弃或转换为 `iterator` 或 `const++_++iterator` 。

en: Erase by Key
zh_Hans: 通过键擦除

en: ```c++ size_type erase(const key_type& k); template<class K> size_type erase(K&& k); ```
zh_Hans: ```c++ size_type erase(const key_type&amp; k); template<class k=""> size_type erase(K&amp;&amp; k); ```</class>

en: Erase all elements with key equivalent to `k`.
zh_Hans: 擦除所有键与 `k` 等价的元素。

en: Returns:;; The number of elements erased. Throws:;; Only throws an exception if it is thrown by `hasher` or `key_equal`. Notes:;; The `template<class K>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs and neither `iterator` nor `const_iterator` are implicitly convertible from `K`. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
zh_Hans: 返回：被擦除的元素数量。抛出：仅当 `hasher` 或 `key_equal` 抛出异常时才会抛出异常。注意：`template<class k="">` 重载仅在以下条件下参与重载决议：`Hash::is_transparent` 和 `Pred::is_transparent` 是有效的成员 typedef，且 `iterator` 和 `const_iterator` 均不能从 `K` 隐式转换。库假定 `Hash` 可同时以 `K` 和 `Key` 调用，且 `Pred` 是透明的。这提供了异构查找能力，从而避免构造 `Key` 类型实例的开销。</class>

en: Erase Range
zh_Hans: 范围擦除

en: Erases the elements in the range from `first` to `last`.
zh_Hans: 擦除从 `first` 到 `last` 范围内的元素。

en: Returns:;; The iterator following the erased elements - i.e. `last`. Throws:;; Nothing in this implementation (neither the `hasher` nor the `key_equal` objects are called).
zh_Hans: 返回：指向被擦除元素之后位置的迭代器，即 `last`。抛出：在此实现中不会抛出异常（既不调用 `hasher` 也不调用 `key_equal` 对象）。

en: swap
zh_Hans: 交换

en: ```c++ void swap(unordered_flat_map& other) noexcept(boost::allocator_traits<Allocator>::is_always_equal::value || boost::allocator_traits<Allocator>::propagate_on_container_swap::value); ```
zh_Hans: ```c++ void swap(unordered_flat_map&amp; other) noexcept(boost::allocator_traits<allocator>::is_always_equal::value || boost::allocator_traits<allocator>::propagate_on_container_swap::value); ```</allocator></allocator>

en: Swaps the contents of the container with the parameter.
zh_Hans: 将容器的内容与参数进行交换。

[ctx: :1123]
en: If `Allocator::propagate_on_container_swap` is declared and `Allocator::propagate_on_container_swap::value` is `true` then the containers' allocators are swapped. Otherwise, swapping with unequal allocators results in undefined behavior.
zh_Hans: 如果 `Allocator::propagate_on_container_swap` 已声明且 `Allocator::propagate_on_container_swap::value` 为 `true`，则交换容器的分配器。否则，使用不相等的分配器进行交换将导致未定义行为。

en: Throws:;; Nothing unless `key_equal` or `hasher` throw on swapping.
zh_Hans: 抛出：除非 `key_equal` 或 `hasher` 在交换时抛出异常，否则不会抛出异常。

en: Move-constructs an `init_value` `x` from the element pointed to by `position`, erases the element and returns `x`.
zh_Hans: 从 `position` 指向的元素移动构造一个 `init_value` 对象 `x`，擦除该元素并返回 `x`。

en: clear
zh_Hans: 清空

en: Erases all elements in the container.
zh_Hans: 擦除容器中的所有元素。

en: Postconditions:;; `size() == 0`, `max_load() >= max_load_factor() * bucket_count()`
zh_Hans: 后置条件：`size() == 0`，`max_load() &gt;= max_load_factor() * bucket_count()`

en: merge
zh_Hans: 合并

en: ```c++ template<class H2, class P2> void merge(unordered_flat_map<Key, T, H2, P2, Allocator>& source); template<class H2, class P2> void merge(unordered_flat_map<Key, T, H2, P2, Allocator>&& source); ```
zh_Hans: ```c++ template<class h2,="" class="" p2=""> void merge(unordered_flat_map<key, t,="" h2,="" p2,="" allocator="">&amp; source); template<class h2,="" class="" p2=""> void merge(unordered_flat_map<key, t,="" h2,="" p2,="" allocator="">&amp;&amp; source); ```</key,></class></key,></class>

en: Move-inserts all the elements from `source` whose key is not already present in `*this`, and erases them from `source`.
zh_Hans: 尝试将 `source` 中所有键尚未出现在 `*this` 内的元素移动插入到 `*this` 中，同时将这些元素从 `source` 移除。

en: Observers
zh_Hans: 观察器

en: get_allocator
zh_Hans: get++_++allocator

en: Returns:;; The container's allocator.
zh_Hans: 返回：容器的分配器。

en: hash_function
zh_Hans: 哈希函数

en: Returns:;; The container's hash function.
zh_Hans: 返回：容器的哈希函数。

en: key_eq
zh_Hans: key++_++eq

en: Returns:;; The container's key equality predicate
zh_Hans: 返回：容器的键相等谓词。

en: Lookup
zh_Hans: 查找

en: ```c++ iterator         find(const key_type& k); const_iterator   find(const key_type& k) const; template<class K> iterator       find(const K& k);
zh_Hans: ```c++ iterator         find(const key_type&amp; k); const_iterator   find(const key_type&amp; k) const; template<class k=""> iterator       find(const K&amp; k);</class>

en: Returns:;; An iterator pointing to an element with key equivalent to `k`, or `end()` if no such element exists. Notes:;; The `template<class K>` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
zh_Hans: 返回：指向键与 `k` 等价的元素的迭代器，若不存在这样的元素则返回 `end()`。注意：`template<class k="">` 重载仅在 `Hash::is_transparent` 和 `Pred::is_transparent` 是有效的成员 typedef 时参与重载决议。库假定 `Hash` 可同时以 `K` 和 `Key` 调用，且 `Pred` 是透明的。该机制支持异构查找，从而避免实例化 `Key` 类型的开销。</class>

en: ```c++ size_type        count(const key_type& k) const; template<class K> size_type      count(const K& k) const; ```
zh_Hans: ```c++ size_type        count(const key_type&amp; k) const; template<class k=""> size_type      count(const K&amp; k) const; ```</class>

en: Returns:;; The number of elements with key equivalent to `k`. Notes:;; The `template<class K>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
zh_Hans: 返回：键与 `k` 等价的元素数量。注意：`template<class k="">` 重载仅在 `Hash::is_transparent` 和 `Pred::is_transparent` 是有效的成员 typedef 时参与重载决议。库假定 `Hash` 可同时以 `K` 和 `Key` 调用，且 `Pred` 是透明的。该机制支持异构查找，从而避免实例化 `Key` 类型的开销。</class>

en: contains
zh_Hans: 包含

en: ```c++ bool             contains(const key_type& k) const; template<class K> bool           contains(const K& k) const; ```
zh_Hans: ```c++ bool             contains(const key_type&amp; k) const; template<class k=""> bool           contains(const K&amp; k) const; ```</class>

en: Returns:;; A boolean indicating whether or not there is an element with key equal to `key` in the container Notes:;; The `template<class K>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
zh_Hans: 返回：一个布尔值，指示容器中是否存在键等于 `key` 的元素。注意：`template<class k="">` 重载仅在 `Hash::is_transparent` 和 `Pred::is_transparent` 是有效的成员 typedef 时参与重载决议。库假定 `Hash` 可同时以 `K` 和 `Key` 调用，且 `Pred` 是透明的。该机制支持异构查找，从而避免实例化 `Key` 类型的开销。</class>

en: equal_range
zh_Hans: equal++_++range

en: ```c++ std::pair<iterator, iterator>               equal_range(const key_type& k); std::pair<const_iterator, const_iterator>   equal_range(const key_type& k) const; template<class K> std::pair<iterator, iterator>             equal_range(const K& k); template<class K> std::pair<const_iterator, const_iterator> equal_range(const K& k) const; ```
zh_Hans: ```c++ std::pair<iterator, iterator="">               equal_range(const key_type&amp; k); std::pair<const_iterator, const_iterator="">   equal_range(const key_type&amp; k) const; template<class k=""> std::pair<iterator, iterator="">             equal_range(const K&amp; k); template<class k=""> std::pair<const_iterator, const_iterator=""> equal_range(const K&amp; k) const; ```</const_iterator,></class></iterator,></class></const_iterator,></iterator,>

en: Returns:;; A range containing all elements with key equivalent to `k`. If the container doesn't contain any such elements, returns `std::make_pair(b.end(), b.end())`. Notes:;; The `template<class K>` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
zh_Hans: 返回：一个布尔值，指示容器中是否存在键等于 `key` 的元素。注意：`template<class k="">` 重载仅在 `Hash::is_transparent` 和 `Pred::is_transparent` 是有效的成员 typedef 时参与重载决议。库假定 `Hash` 可同时以 `K` 和 `Key` 调用，且 `Pred` 是透明的。该机制支持异构查找，从而避免实例化 `Key` 类型的开销。</class>

en: operator++[++++]++
zh_Hans: operator++[]++

en: ```c++ mapped_type& operator[](const key_type& k); mapped_type& operator[](key_type&& k); template<class K> mapped_type& operator[](K&& k); ```
zh_Hans: ```c++ mapped_type&amp; operator[](const key_type&amp; k); mapped_type&amp; operator[](key_type&amp;&amp; k); template<class k=""> mapped_type&amp; operator[](K&amp;&amp; k); ```</class>

en: Effects:;; If the container does not already contain an element with a key equivalent to `k`, inserts the value `std::pair<key_type const, mapped_type>(k, mapped_type())`. Returns:;; A reference to `x.second` where `x` is the element already in the container, or the newly inserted element with a key equivalent to `k`. Throws:;; If an exception is thrown by an operation other than a call to `hasher` the function has no effect. Notes:;; Can invalidate iterators, pointers and references, but only if the insert causes the load to be greater than the maximum load. + + The `template<class K>` overload only participates in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
zh_Hans: 效果：如果容器尚未包含键与 `k` 等价的元素，则插入值 `std::pair<key_type const,="" mapped_type="">(k, mapped_type())`。返回：对 `x.second` 的引用，其中 `x` 是容器中已存在的元素，或键与 `k` 等价的新插入元素。抛出：如果调用 `hasher` 以外的操作抛出异常，则该函数无效果。注意：可能会导致迭代器、指针和引用失效，但仅当插入操作导致负载因子超过最大负载因子时才会发生。+ +`template<class k="">` 重载仅在 `Hash::is_transparent` 和 `Pred::is_transparent` 是有效的成员 typedef 时参与重载决议。库假定 `Hash` 可同时以 `K` 和 `Key` 调用，且 `Pred` 是透明的。该机制支持异构查找，从而避免实例化 `Key` 类型的开销。</class></key_type>

en: ```c++ mapped_type& at(const key_type& k); const mapped_type& at(const key_type& k) const; template<class K> mapped_type& at(const K& k); template<class K> const mapped_type& at(const K& k) const; ```
zh_Hans: ```c++ mapped_type&amp; at(const key_type&amp; k); const mapped_type&amp; at(const key_type&amp; k) const; template<class k=""> mapped_type&amp; at(const K&amp; k); template<class k=""> const mapped_type&amp; at(const K&amp; k) const; ```</class></class>

en: Returns:;; A reference to `x.second` where `x` is the (unique) element whose key is equivalent to `k`. Throws:;; An exception object of type `std::out_of_range` if no such element is present. Notes:;; The `template<class K>` overloads only participate in overload resolution if `Hash::is_transparent` and `Pred::is_transparent` are valid member typedefs. The library assumes that `Hash` is callable with both `K` and `Key` and that `Pred` is transparent. This enables heterogeneous lookup which avoids the cost of instantiating an instance of the `Key` type.
zh_Hans: 返回：对 `x.second` 的引用，其中 `x` 是键与 `k` 等价的（唯一）元素。抛出：如果不存在这样的元素，则抛出 `std::out_of_range` 类型的异常对象。注意：`template<class k="">` 重载仅在 `Hash::is_transparent` 和 `Pred::is_transparent` 是有效的成员 typedef 时参与重载决议。库假定 `Hash` 可同时以 `K` 和 `Key` 调用，且 `Pred` 是透明的。该机制支持异构查找，从而避免实例化 `Key` 类型的开销。</class>

en: Bucket Interface
zh_Hans: 桶接口

en: Returns:;; The size of the bucket array.
zh_Hans: 返回：桶数组的大小。

en: Hash Policy
zh_Hans: 哈希策略

en: load_factor
zh_Hans: 负载因子

en: Returns:;; `static_cast<float>(size())/static_cast<float>(bucket_count())`, or `0` if `bucket_count() == 0`.
zh_Hans: 返回：`static_cast<float>(size())/static_cast<float>(bucket_count())`，若 `bucket_count() == 0` 则返回 `0`。</float></float>

en: max_load_factor
zh_Hans: max++_++load++_++factor（最大负载因子）

en: Returns:;; Returns the container's maximum load factor.
zh_Hans: 返回：容器的最大负载因子。

en: Set max_load_factor
zh_Hans: 设置最大负载因子

en: Effects:;; Does nothing, as the user is not allowed to change this parameter. Kept for compatibility with `boost::unordered_map`.
zh_Hans: 效果：不执行任何操作，因为用户不允许更改此参数。为与 `boost::unordered_map` 保持兼容而保留。

en: max_load
zh_Hans: max++_++load（最大负载）

en: Returns:;; The maximum number of elements the container can hold without rehashing, assuming that no further elements will be erased. Note:;; After construction, rehash or clearance, the container's maximum load is at least `max_load_factor() * bucket_count()`. This number may decrease on erasure under high-load conditions.
zh_Hans: 返回：在不进行 rehash 的前提下，容器所能容纳的最大元素数量（假设不会有更多元素被擦除）。注意：在构造、rehash 或清空之后，容器的最大负载至少为 `max_load_factor() * bucket_count()`。在高负载条件下，该值可能因擦除操作而减小。

en: rehash
zh_Hans: 重哈希

en: Changes if necessary the size of the bucket array so that there are at least `n` buckets, and so that the load factor is less than or equal to the maximum load factor. When applicable, this will either grow or shrink the `bucket_count()` associated with the container.
zh_Hans: 如有必要，将改变桶数组的大小，使其至少包含 `n` 个桶，并确保负载因子小于或等于最大负载因子。此操作将根据情况增加或减少容器的 `bucket++_++count()` 。

en: When `size() == 0`, `rehash(0)` will deallocate the underlying buckets array. If the provided Allocator uses fancy pointers, a default allocation is subsequently performed.
zh_Hans: 当 `size() == 0` 时，`rehash(0)` 将释放底层桶数组。如果提供的分配器使用花式指针，则随后会执行一次默认分配。

[ctx: :1355]
en: Invalidates iterators, pointers and references, and changes the order of elements.
zh_Hans: 使迭代器、指针和引用失效，并改变元素的顺序。

[ctx: :1358]
en: Throws:;; The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function.
zh_Hans: 抛出：若抛出异常（除非由容器的哈希函数或比较函数抛出），则该函数无效果。

en: reserve
zh_Hans: 保留

en: Equivalent to `a.rehash(ceil(n / a.max_load_factor()))`.
zh_Hans: 等价于 `a.rehash(ceil(n / a.max_load_factor()))`。

en: Similar to `rehash`, this function can be used to grow or shrink the number of buckets in the container.
zh_Hans: 与 `rehash` 类似，该函数可用于增加或减少容器中的桶数量。

[ctx: :1371]
en: Invalidates iterators, pointers and references, and changes the order of elements.
zh_Hans: 使迭代器、指针和引用失效，并改变元素的顺序。

[ctx: :1374]
en: Throws:;; The function has no effect if an exception is thrown, unless it is thrown by the container's hash function or comparison function.
zh_Hans: 抛出：若抛出异常（除非由容器的哈希函数或比较函数抛出），则该函数无效果。

en: Statistics
zh_Hans: 统计信息

en: get_stats
zh_Hans: get++_++stats

en: Returns:;; A statistical description of the insertion and lookup operations performed by the container so far. Notes:;; Only available if xref:reference/stats.adoc#stats[statistics calculation] is xref:unordered_flat_map_boost_unordered_enable_stats[enabled].
zh_Hans: 返回：对容器迄今为止执行的插入和查找操作的统计描述。注意：仅当 xref:reference/stats.adoc#stats[统计计算] 被 xref:unordered_flat_map_boost_unordered_enable_stats[启用] 时可用。

en: reset_stats
zh_Hans: reset++_++stats

en: Effects:;; Sets to zero the internal statistics kept by the container. Notes:;; Only available if xref:reference/stats.adoc#stats[statistics calculation] is xref:unordered_flat_map_boost_unordered_enable_stats[enabled].
zh_Hans: 效果：将容器内部保持的统计信息重置为零。注意：仅当 xref:reference/stats.adoc#stats[统计计算] 被 xref:unordered_flat_map_boost_unordered_enable_stats[启用] 时可用。

en: Deduction Guides
zh_Hans: 推导指引

en: A deduction guide will not participate in overload resolution if any of the following are true:
zh_Hans: 如果以下任何一条件为真，则推导指引将不参与重载决议：

en: - It has an `InputIterator` template parameter and a type that does not qualify as an input iterator is deduced for that parameter. - It has an `Allocator` template parameter and a type that does not qualify as an allocator is deduced for that parameter. - It has a `Hash` template parameter and an integral type or a type that qualifies as an allocator is deduced for that parameter. - It has a `Pred` template parameter and a type that qualifies as an allocator is deduced for that parameter.
zh_Hans: - 该推导指引包含 `InputIterator` 模板参数，且为此参数推导出的类型不符合输入迭代器的要求。 - 该推导指引包含 `Allocator` 模板参数，且为该参数推导出的类型不符合分配器要求。 - 该推导指引包含 `Hash` 模板参数，且为该参数推导出的类型为整型或符合分配器要求。 - 该推导指引包含 `Pred` 模板参数，且为该参数推导出的类型符合分配器要求。

en: A `size_­type` parameter type in a deduction guide refers to the `size_­type` member type of the container type deduced by the deduction guide. Its default value coincides with the default value of the constructor selected.
zh_Hans: 推导指引中的 `size++_++type` 参数类型，指向由该推导指引所推导容器类型的 `size++_++type` 成员类型。其默认值与所选构造函数的默认值一致。

en: Equality Comparisons
zh_Hans: 相等性比较

en: ```c++ template<class Key, class T, class Hash, class Pred, class Alloc> bool operator==(const unordered_flat_map<Key, T, Hash, Pred, Alloc>& x, const unordered_flat_map<Key, T, Hash, Pred, Alloc>& y); ```
zh_Hans: ```c++ template<class key,="" class="" t,="" hash,="" pred,="" alloc=""> bool operator==(const unordered_flat_map<key, t,="" hash,="" pred,="" alloc="">&amp; x, const unordered_flat_map<key, t,="" hash,="" pred,="" alloc="">&amp; y); ```</key,></key,></class>

en: Return `true` if `x.size() == y.size()` and for every element in `x`, there is an element in `y` with the same key, with an equal value (using `operator==` to compare the value types).
zh_Hans: 若 `x.size() == y.size()` 且对于 `x` 中的每个元素，在 `y` 中均存在一个具有相同键且值相等（使用 `operator==` 比较值类型）的元素，则返回 `true`。

[ctx: :1459]
en: Notes:;; Behavior is undefined if the two containers don't have equivalent equality predicates.
zh_Hans: 注意：如果两个容器的相等谓词不等价，则行为未定义。

en: ```c++ template<class Key, class T, class Hash, class Pred, class Alloc> bool operator!=(const unordered_flat_map<Key, T, Hash, Pred, Alloc>& x, const unordered_flat_map<Key, T, Hash, Pred, Alloc>& y); ```
zh_Hans: ```c++ template<class key,="" class="" t,="" hash,="" pred,="" alloc=""> bool operator!=(const unordered_flat_map<key, t,="" hash,="" pred,="" alloc="">&amp; x, const unordered_flat_map<key, t,="" hash,="" pred,="" alloc="">&amp; y); ```</key,></key,></class>

en: Return `false` if `x.size() == y.size()` and for every element in `x`, there is an element in `y` with the same key, with an equal value (using `operator==` to compare the value types).
zh_Hans: 若 `x.size() == y.size()` 且对于 `x` 中的每个元素，在 `y` 中均存在一个具有相同键且值相等（使用 `operator==` 比较值类型）的元素，则返回 `false`。

[ctx: :1473]
en: Notes:;; Behavior is undefined if the two containers don't have equivalent equality predicates.
zh_Hans: 注意：如果两个容器的相等谓词不等价，则行为未定义。

en: Swap
zh_Hans: 交换

en: ```c++ template<class Key, class T, class Hash, class Pred, class Alloc> void swap(unordered_flat_map<Key, T, Hash, Pred, Alloc>& x, unordered_flat_map<Key, T, Hash, Pred, Alloc>& y) noexcept(noexcept(x.swap(y))); ```
zh_Hans: ```c++ template<class key,="" class="" t,="" hash,="" pred,="" alloc=""> void swap(unordered_flat_map<key, t,="" hash,="" pred,="" alloc="">&amp; x, unordered_flat_map<key, t,="" hash,="" pred,="" alloc="">&amp; y) noexcept(noexcept(x.swap(y))); ```</key,></key,></class>

en: Swaps the contents of `x` and `y`.
zh_Hans: 交换 `x` 和 `y` 的内容。

[ctx: :1485]
en: If `Allocator::propagate_on_container_swap` is declared and `Allocator::propagate_on_container_swap::value` is `true` then the containers' allocators are swapped. Otherwise, swapping with unequal allocators results in undefined behavior.
zh_Hans: 如果 `Allocator::propagate_on_container_swap` 已声明且 `Allocator::propagate_on_container_swap::value` 为 `true`，则交换容器的分配器。否则，使用不相等的分配器进行交换将导致未定义行为。

en: Effects:;; `x.swap(y)` Throws:;; Nothing unless `key_equal` or `hasher` throw on swapping.
zh_Hans: 效果：`x.swap(y)` 抛出：除非 `key_equal` 或 `hasher` 在交换时抛出异常，否则不会抛出异常。

en: erase_if
zh_Hans: erase++_++if

en: ```c++ template<class K, class T, class H, class P, class A, class Predicate> typename unordered_flat_map<K, T, H, P, A>::size_type erase_if(unordered_flat_map<K, T, H, P, A>& c, Predicate pred); ```
zh_Hans: ```c++ template<class k,="" class="" t,="" h,="" p,="" a,="" predicate=""> typename unordered_flat_map<k, t,="" h,="" p,="" a="">::size_type erase_if(unordered_flat_map<k, t,="" h,="" p,="" a="">&amp; c, Predicate pred); ```</k,></k,></class>

en: Traverses the container `c` and removes all elements for which the supplied predicate returns `true`.
zh_Hans: 遍历容器 `c`，并移除所有使得给定谓词返回 `true` 的元素。

en: Returns:;; The number of erased elements. Notes:;; Equivalent to: + + ```c++ auto original_size = c.size(); for (auto i = c.begin(), last = c.end(); i != last; ) { if (pred(*i)) { i = c.erase(i); } else { ++i; } } return original_size - c.size(); ``` + Note that the references passed to `pred` are non-const.
zh_Hans: 返回：被擦除的元素数量。注意：等价于：`auto original_size = c.size(); for (auto i = c.begin(), last = c.end(); i != last; ) { if (pred(*i)) { i = c.erase(i); } else { ++i; } } return original_size - c.size();` 注意：传递给 `pred` 的引用是非常量的。

en: Serialization
zh_Hans: 序列化

en: ``unordered_flat_map``s can be archived/retrieved by means of link:../../../../../serialization/index.html[Boost.Serialization^] using the API provided by this library. Both regular and XML archives are supported.
zh_Hans: `unordered++_++flat++_++map` 可通过本组件库提供的 API，借助 link:../../../../../serialization/index.html[Boost.Serialization] 进行归档/检索。支持常规归档与 XML 归档两种格式。

en: Saving an unordered_flat_map to an archive
zh_Hans: 将 unordered++_++flat++_++map 保存到归档

en: Saves all the elements of an `unordered_flat_map` `x` to an archive (XML archive) `ar`.
zh_Hans: 将 `unordered++_++flat++_++map` `x` 的所有元素保存到归档（XML 归档） `ar` 。

en: Requires:;; `std::remove_const<key_type>::type` and `std::remove_const<mapped_type>::type` are serializable (XML serializable), and they do support Boost.Serialization `save_construct_data`/`load_construct_data` protocol (automatically suported by https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[DefaultConstructible^] types).
zh_Hans: 要求：std::remove_const<key_type>::type 和 std::remove_const<mapped_type>::type 必须满足可序列化要求（XML 可序列化），且需要支持 Boost.Serialization 的 save_construct_data / load_construct_data 协议（该协议自动支持 https://en.cppreference.com/w/cpp/named_req/DefaultConstructible[可默认构造] 要求）。</mapped_type></key_type>

en: Loading an unordered_flat_map from an archive
zh_Hans: 从归档加载 unordered++_++flat++_++map

en: Deletes all preexisting elements of an `unordered_flat_map` `x` and inserts from an archive (XML archive) `ar` restored copies of the elements of the original `unordered_flat_map` `other` saved to the storage read by `ar`.
zh_Hans: 删除 `unordered++_++flat++_++map` 容器 `x` 中所有已存在的元素，并从归档（XML 归档） `ar` 中插入原始 `unordered++_++flat++_++map` 容器 `other` 的元素副本，这些副本是从 `ar` 所读取的存储中恢复的。

en: Requires:;; `x.key_equal()` is functionally equivalent to `other.key_equal()`.
zh_Hans: 要求;; `x.key++_++equal()` 需要在功能上等价于 `other.key++_++equal()` 。

en: Saving an iterator/const_iterator to an archive
zh_Hans: 将迭代器/常量迭代器保存到归档

en: Saves the positional information of an `iterator` (`const_iterator`) `it` to an archive (XML archive) `ar`. `it` can be and `end()` iterator.
zh_Hans: 将 `iterator` （ `const++_++iterator` ）常量迭代器 `it` 的位置信息保存到归档（XML 归档） `ar` 中。 `it` 可以是 `end()` 迭代器。

en: Requires:;; The `unordered_flat_map` `x` pointed to by `it` has been previously saved to `ar`, and no modifying operations have been issued on `x` between saving of `x` and saving of `it`.
zh_Hans: 要求;; `it` 所指向的 `unordered++_++flat++_++map` 容器 `x` 必须先前已保存至 `ar` ，且在保存 `x` 与保存 `it` 期间不得对 `x` 执行任何修改操作。

en: Loading an iterator/const_iterator from an archive
zh_Hans: 从归档加载迭代器/常量迭代器

en: Makes an `iterator` (`const_iterator`) `it` point to the restored position of the original `iterator` (`const_iterator`) saved to the storage read by an archive (XML archive) `ar`.
zh_Hans: 使 `iterator` （ `const++_++iterator` ） `it` 指向原始 `iterator` （ `const++_++iterator` ）所恢复的位置。该原始迭代器已被保存到由归档（XML 归档） `ar` 读取的存储中。

en: Requires:;; If `x` is the `unordered_flat_map` `it` points to, no modifying operations have been issued on `x` between loading of `x` and loading of `it`.
zh_Hans: 要求;; 若 `x` 是 `it` 所指向的 `unordered++_++flat++_++map` 容器，则在加载 `x` 与加载 `it` 期间不得对 `x` 执行任何修改操作。
