en	﻿[#regular] = Regular Containers
zh-hans	[#regular] = 常规容器

en	:idprefix: regular_

en	Boost.Unordered closed-addressing containers (`boost::unordered_set`, `boost::unordered_map`, `boost::unordered_multiset` and `boost::unordered_multimap`) are fully conformant with the C++ specification for unordered associative containers, so for those who know how to use `std::unordered_set`, `std::unordered_map`, etc., their homonyms in Boost.Unordered are drop-in replacements. The interface of open-addressing containers (`boost::unordered_node_set`, `boost::unordered_node_map`, `boost::unordered_flat_set` and `boost::unordered_flat_map`) is very similar, but they present some minor differences listed in the dedicated xref:compliance.adoc#compliance_open_addressing_containers[standard compliance section].
zh-hans	Boost.Unordered 的闭寻址容器（ `boost::unordered++_++set` 、 `boost::unordered++_++map` 、 `boost::unordered++_++multiset` 与 `boost::unordered++_++multimap` ）完全符合 C{plus}{plus} 无序关联容器的标准规范。因此，对于熟悉 `std::unordered++_++set` 、 `std::unordered++_++map` 等用法的用户，可直接将其替换为Boost.Unordered 中的同名容器。开放寻址容器（ `boost::unordered++_++node++_++set` 、 `boost::unordered++_++node++_++map` 、 `boost::unordered++_++flat++_++set` 和 `boost::unordered++_++flat++_++map` ）的接口与之高度相似，但存在一些细微差异，详见专门的 xref:compliance.adoc#compliance_open_addressing_containers[标准符合性章节] 。

en	For readers without previous experience with hash containers but familiar with normal associative containers (`std::set`, `std::map`, `std::multiset` and `std::multimap`), Boost.Unordered containers are used in a similar manner:
zh-hans	对于没有哈希容器经验但熟悉常规关联容器（ `std::set` 、 `std::map` 、 `std::multiset` 和 `std::multimap` ）的读者，Boost.Unordered 容器的使用方式与之类似：

en	But since the elements aren't ordered, the output of:
zh-hans	但由于元素不按顺序存储，以下代码的输出结果：

en	can be in any order. For example, it might be:
zh-hans	可能以任意顺序输出。例如，结果可能为：

en	There are other differences, which are listed in the xref:regular.adoc#comparison[Comparison with Associative Containers] section.
zh-hans	其他差异列于 xref:regular.adoc#comparison[与关联容器的对比] 章节中。

en	Iterator Invalidation
zh-hans	迭代器失效

en	It is not specified how member functions other than `rehash` and `reserve` affect the bucket count, although `insert` can only invalidate iterators when the insertion causes the container's load to be greater than the maximum allowed. For most implementations this means that `insert` will only change the number of buckets when this happens. Iterators can be invalidated by calls to `insert`, `rehash` and `reserve`.
zh-hans	标准未明确规定除 `rehash` 和 `reserve` 之外的成员函数如何影响桶数量，但 `insert` 操作仅当导致容器负载超过最大允许值时才会使迭代器失效。在大多数实现中，这意味着 `insert` 仅在此种情况下才会改变桶的数量。迭代器可能因调用 `insert` 、 `rehash` 或 `reserve` 而失效。

en	As for pointers and references, they are never invalidated for node-based containers (`boost::unordered_[multi]set`, `boost::unordered_[multi]map`, `boost::unordered_node_set`, `boost::unordered_node_map`), but they will be when rehashing occurs for `boost::unordered_flat_set` and `boost::unordered_flat_map`: this is because these containers store elements directly into their holding buckets, so when allocating a new bucket array the elements must be transferred by means of move construction.
zh-hans	对于基于节点的容器（ `boost::unordered++_[++multi++]++set` 、 `boost::unordered++_[++multi++]++map` 、 `boost::unordered++_++node++_++set` 、 `boost::unordered++_++node++_++map` ），其指针和引用永远不会失效。但对于 `boost::unordered++_++flat++_++set` 和 `boost::unordered++_++flat++_++map` ，在发生重哈希时指针和引用将会失效：这是因为这些容器将元素直接存储在桶中，当分配新的桶数组时，必须通过移动构造来转移元素。

en	In a similar manner to using `reserve` for ``vector``s, it can be a good idea to call `reserve` before inserting a large number of elements. This will get the expensive rehashing out of the way and let you store iterators, safe in the knowledge that they won't be invalidated. If you are inserting `n` elements into container `x`, you could first call:
zh-hans	与为 `vector` 使用 `reserve` 类似，在插入大量元素之前调用 `reserve` 是一个好主意。这样可以避免代价高昂的重哈希操作，并且让你能够存储迭代器，确信它们不会被失效。如果你要向容器 `x` 插入 `n` 个元素，可以先调用：

en	``` x.reserve(n); ```

en	`reserve(n)` reserves space for at least `n` elements, allocating enough buckets
zh-hans	`reserve(n)` 为至少 `n` 个元素预留空间，分配足够数量的桶，

en	so as to not exceed the maximum load factor. + Because the maximum load factor is defined as the number of elements divided by the total number of available buckets, this function is logically equivalent to: + ``` x.rehash(std::ceil(n / x.max_load_factor())) ``` + See the xref:reference/unordered_map.adoc#unordered_map_rehash[reference for more details] on the `rehash` function.
zh-hans	以确保不超过最大负载因子。由于最大负载因子定义为元素数量除以可用桶的总数，该函数在逻辑上等价于： ```cppx.rehash(std::ceil(n / x.max_load_factor()))``` 有关 `rehash` 函数的更多详细信息，请参阅 xref:reference/unordered_map.adoc#unordered_map_rehash[参考文档]。

en	:idprefix: comparison_

en	Comparison with Associative Containers
zh-hans	与关联容器的对比

en	Associative Containers
zh-hans	关联容器

en	Unordered Associative Containers
zh-hans	无序关联容器

en	Parameterized by an ordering relation `Compare`
zh-hans	通过排序关系 `Compare` 进行 参数化

en	Parameterized by a function object `Hash` and an equivalence relation `Pred`
zh-hans	由函数对象`哈希对象`和等价关系`谓词对象`参数化。

en	Keys can be compared using `key_compare` which is accessed by member function `key_comp()`, values can be compared using `value_compare` which is accessed by member function `value_comp()`.
zh-hans	键可通过成员函数`key_comp()`获取的`键比较对象`进行比较，值可通过成员函数`value_comp()`获取的`值比较对象`进行比较。

en	Keys can be hashed using `hasher` which is accessed by member function `hash_function()`, and checked for equality using `key_equal` which is accessed by member function `key_eq()`. There is no function object for compared or hashing values.
zh-hans	键可通过成员函数`hash_function()`获取的`哈希对象`进行哈希计算，并通过成员函数`key_eq()`获取的`键相等比较对象`检查是否相等。不存在用于值比较或值哈希的函数对象。

en	Constructors have optional extra parameters for the comparison object.
zh-hans	构造函数包含用于比较对象的可选额外参数。

en	Constructors have optional extra parameters for the initial minimum number of buckets, a hash function and an equality object.
zh-hans	构造函数包含可选的额外参数，用于指定初始最小哈希桶数量、哈希函数以及相等性判断对象。

en	Keys `k1`, `k2` are considered equivalent if `!Compare(k1, k2) && !Compare(k2, k1)`.
zh-hans	若`!对象(k1, k2) &amp;&amp; !对象(k2, k1)`，则键`k1`、`k2`视为等价。

en	Keys `k1`, `k2` are considered equivalent if `Pred(k1, k2)`
zh-hans	若`谓词对象(k1, k2)成立`，则键`k1`、`k2`视为等价。

en	Member function `lower_bound(k)` and `upper_bound(k)`
zh-hans	成员函数`lower_bound(k)`和`upper_bound(k)`

en	No equivalent. Since the elements aren't ordered `lower_bound` and `upper_bound` would be meaningless.
zh-hans	无对应接口。由于元素无序，`lower_bound `和 `upper_bound `无实际意义。

en	`equal_range(k)` returns an empty range at the position that `k` would be inserted if `k` isn't present in the container.
zh-hans	若键k不存在于容器中，equal_range(k)会在k 应插入的位置返回一个空区间。

en	`equal_range(k)` returns a range at the end of the container if `k` isn't present in the container. It can't return a positioned range as `k` could be inserted into multiple place. +
zh-hans	equal_range(k) 若键k不存在于容器中，则返回容器末尾的区间。该函数无法返回定位区间，因为k可被插入到多个位置。

en	**Closed-addressing containers:** To find out the bucket that `k` would be inserted into use `bucket(k)`. But remember that an insert can cause the container to rehash - meaning that the element can be inserted into a different bucket.
zh-hans	闭散列容器：使用 bucket (k) 可确定键 k 待插入的哈希桶。需注意，插入操作可能触发容器重新哈希，元素最终会被存入其他哈希桶。

en	`iterator`, `const_iterator` are of the bidirectional category.
zh-hans	`迭代器`、`常迭代器`的迭代类别为双向迭代器。

en	`iterator`, `const_iterator` are of at least the forward category.
zh-hans	`迭代器`、`常迭代器`的迭代类别至少为前向迭代器。

en	Iterators, pointers and references to the container's elements are never invalidated.
zh-hans	指向容器元素的迭代器、指针和引用永远不会失效。

en	xref:regular.adoc#regular_iterator_invalidation[Iterators can be invalidated by calls to insert or rehash]. +
zh-hans	xref:regular.adoc#regular_iterator_invalidation [调用 insert 或 rehash 可能会导致迭代器失效]。

en	**Node-based containers:** Pointers and references to the container's elements are never invalidated. + **Flat containers:** Pointers and references to the container's elements are invalidated when rehashing occurs.
zh-hans	基于节点的容器：指向容器元素的指针和引用永远不会失效。 扁平容器：发生重新哈希时，指向容器元素的指针和引用将会失效。

en	Iterators iterate through the container in the order defined by the comparison object.
zh-hans	迭代器按照比较对象定义的顺序遍历容器。

en	Iterators iterate through the container in an arbitrary order, that can change as elements are inserted, although equivalent elements are always adjacent.
zh-hans	迭代器以任意顺序遍历容器，该顺序会随元素插入发生变化，但等价元素始终保持相邻。

en	No equivalent
zh-hans	无对应接口

en	**Closed-addressing containers:** Local iterators can be used to iterate through individual buckets. (The order of local iterators and iterators aren't required to have any correspondence.)
zh-hans	闭散列容器：本地迭代器可用于遍历各个哈希桶。（本地迭代器与迭代器的顺序无需存在对应关系。）

en	Can be compared using the `==`, `!=`, `<`, `\<=`, `>`, `>=` operators.
zh-hans	可使用`==`, `!=`, `&lt;`, `\&lt;=`, `&gt;`, `&gt;=`运算符进行比较。

en	Can be compared using the `==` and `!=` operators.
zh-hans	可使用`==` 和`!=`运算符进行比较。

en	When inserting with a hint, implementations are permitted to ignore the hint.
zh-hans	使用提示迭代器插入元素时，实现允许忽略该提示。

en	---

en	Operation
zh-hans	操作

en	Associative Containers
zh-hans	关联容器

en	Unordered Associative Containers
zh-hans	无序关联容器

en	Construction of empty container
zh-hans	空容器的构造

en	constant
zh-hans	常数级

en	O(_n_) where _n_ is the minimum number of buckets.
zh-hans	O(_n_)，其中 _n_ 是最小桶数。

en	Construction of container from a range of _N_ elements
zh-hans	由_N_元素的区间构造容器

en	O(_N log N_), O(_N_) if the range is sorted with `value_comp()`
zh-hans	O(_N log N_)，如果区间已按 `value_comp()` 排序则为 O(_N_)

en	Average case O(_N_), worst case O(_N^2^_)
zh-hans	平均时间复杂度 O(_N_)，最坏时间复杂度 O(_N^2^_)

en	Insert a single element
zh-hans	插入单个元素

en	logarithmic
zh-hans	对数级

en	Average case constant, worst case linear
zh-hans	平均情况为常数时间，最坏情况为线性时间

en	Insert a single element with a hint
zh-hans	带提示插入单个元素

en	Amortized constant if `t` elements inserted right after hint, logarithmic otherwise
zh-hans	若在提示位置后直接插入t个元素，则为均摊常数时间；否则为对数时间

en	Average case constant, worst case linear (ie. the same as a normal insert).
zh-hans	平均情况为常数时间，最坏情况为线性时间（即与普通插入操作一致）。

en	Inserting a range of _N_ elements
zh-hans	插入_N_元素的区间

en	_N_ log(`size()` + _N_)

en	Average case O(_N_), worst case O(_N_ * `size()`)
zh-hans	平均时间复杂度 O(_N_)，最坏时间复杂度O (_N_ * `size()`)

en	Erase by key, `k`
zh-hans	按键`k`移除

en	O(log(`size()`) + `count(k)`)

en	Average case: O(`count(k)`), Worst case: O(`size()`)
zh-hans	平均情况：O(`count(k)`)，最坏情况：O(`size()`)

en	Erase a single element by iterator
zh-hans	通过迭代器移除单个元素

en	Amortized constant
zh-hans	均摊常数时间

en	Average case: O(1), Worst case: O(`size()`)
zh-hans	平均情况：O (1)，最坏情况：O(`size()`)

en	Erase a range of _N_ elements
zh-hans	移除 _N_元素的区间

en	O(log(`size()`) + _N_)

en	Average case: O(_N_), Worst case: O(`size()`)
zh-hans	平均情况：O(_N_)，最坏情况： O(`size()`)

en	Clearing the container
zh-hans	清空容器

en	O(`size()`)

en	Find
zh-hans	查找

en	Count
zh-hans	计数

en	`equal_range(k)`

en	`lower_bound`,`upper_bound`

en	n/a