在线文档教程
C++
容器 | Containers

std::unordered_set::unordered_set

STD:无序[医]成套::无序[医]集

(1)
explicit unordered_set( size_type bucket_count = /*implementation-defined*/, const Hash& hash = Hash(), const KeyEqual& equal = KeyEqual(), const Allocator& alloc = Allocator() (since C++11) (until C++14)
unordered_set() : unordered_set( size_type(/*implementation-defined*/) ) {} explicit unordered_set( size_type bucket_count, const Hash& hash = Hash(), const KeyEqual& equal = KeyEqual(), const Allocator& alloc = Allocator() (since C++14)
unordered_set( size_type bucket_count, const Allocator& alloc ) : unordered_set(bucket_count, Hash(), KeyEqual(), alloc) {} unordered_set( size_type bucket_count, const Hash& hash, const Allocator& alloc ) : unordered_set(bucket_count, hash, KeyEqual(), alloc) {}(1)(since C++14)
explicit unordered_set( const Allocator& alloc (1)(since C++11)
template< class InputIt > unordered_set( InputIt first, InputIt last, size_type bucket_count = /*implementation-defined*/, const Hash& hash = Hash(), const KeyEqual& equal = KeyEqual(), const Allocator& alloc = Allocator() (2)(since C++11)
template< class InputIt > unordered_set( InputIt first, InputIt last, size_type bucket_count, const Allocator& alloc ) : unordered_set(first, last, bucket_count, Hash(), KeyEqual(), alloc) {}(2)(since C++14)
template< class InputIt > unordered_set( InputIt first, InputIt last, size_type bucket_count, const Hash& hash, const Allocator& alloc ) : unordered_set(first, last, bucket_count, hash, KeyEqual(), alloc) {}(2)(since C++14)
unordered_set( const unordered_set& other (3)(since C++11)
unordered_set( const unordered_set& other, const Allocator& alloc (3)(since C++11)
unordered_set( unordered_set&& other (4)(since C++11)
unordered_set( unordered_set&& other, const Allocator& alloc (4)(since C++11)
unordered_set( std::initializer_list<value_type> init, size_type bucket_count = /*implementation-defined*/, const Hash& hash = Hash(), const KeyEqual& equal = KeyEqual(), const Allocator& alloc = Allocator() (5)(since C++11)
unordered_set( std::initializer_list<value_type> init, size_type bucket_count, const Allocator& alloc ) : unordered_set(init, bucket_count, Hash(), KeyEqual(), alloc) {}(5)(since C++14)
unordered_set( std::initializer_list<value_type> init, size_type bucket_count, const Hash& hash, const Allocator& alloc ) : unordered_set(init, bucket_count, hash, KeyEqual(), alloc) {}(5)(since C++14)

从各种数据源构造新容器。可选地使用所提供的用户bucket_count作为要创建的最少数量的桶,hash作为散列函数,equal作为比较键和alloc作为分配器。

1%29构造空容器。集max_load_factor()到1.0。对于默认构造函数,桶的数量是实现定义的。

2%29构造包含范围内容的容器。[first, last).成套max_load_factor()如果范围中的多个元素具有比较等价的键,则未指定插入了%28挂起的元素LWG2844%29

3%29复制构造函数。的内容的副本构造容器。other,复制加载因子、谓词和哈希函数。如果alloc不提供,则通过调用std::allocator_traits<allocator_type>::select_on_container_copy_construction(other.get_allocator())...

4%29移动构造函数。的内容构造容器。other使用移动语义。如果alloc如果不提供分配器,则通过移动构造从属于other...

5%29使用初始化程序列表的内容构造容器。init,和无序一样[医]设置%28 init.start%28%29,init.end%28%29%29。

参数

alloc-allocator to use for all memory allocations of this container
bucket_count-minimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used
hash-hash function to use
equal-comparison function to use for all key comparisons of this container
first, last-the range to copy the elements from
other-another container to be used as source to initialize the elements of the container with
init-initializer list to initialize the elements of the container with

类型要求

-输入必须符合输入器的要求。

复杂性

1%29常数

2%29平均情况下线性最坏情况二次之间的距离firstlast

3%29线性other

4%29常数。如果alloc被赋予和alloc != other.get_allocator(),然后是线性的。

5%29平均线性最坏情况二次型init

注记

在容器移动构造%28重载%284%29%29之后,引用、指针和迭代器%28---other保持有效,但引用当前在*this.现行标准通过第23.2.1节中的总括声明作出这一保证。集装箱。所需经费/12,目前正在考虑通过以下方式提供更直接的担保:lwg 2321...

另见

operator=assigns values to the container (public member function)

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/container/unorder[医]设置/无序[医]集