Namespaces
Variants

std::flat_multimap<Key,T,Compare,KeyContainer,MappedContainer>:: flat_multimap

From cppreference.net

flat_multimap ( )
: flat_multimap ( key_compare ( ) ) { }
(1) (C++23 起)
template < class Allocator >
flat_multimap ( const flat_multimap & , const Allocator & alloc ) ;
(2) (自 C++23 起)
template < class Allocator >
flat_multimap ( flat_multimap && , const Allocator & alloc ) ;
(3) (自 C++23 起)
flat_multimap ( key_container_type key_cont, mapped_container_type mapped_cont,
const key_compare & comp = key_compare ( ) ) ;
(4) (自 C++23 起)
template < class Allocator >

flat_multimap ( const key_container_type & key_cont,
const mapped_container_type & mapped_cont,

const Allocator & alloc ) ;
(5) (C++23 起)
template < class Allocator >

flat_multimap ( const key_container_type & key_cont,
const mapped_container_type & mapped_cont,

const key_compare & comp, const Allocator & alloc ) ;
(6) (自 C++23 起)
flat_multimap ( std:: sorted_equivalent_t , key_container_type key_cont,

mapped_container_type mapped_cont,

const key_compare & comp = key_compare ( ) ) ;
(7) (C++23 起)
template < class Allocator >

flat_multimap ( std:: sorted_equivalent_t , const key_container_type & key_cont,

const mapped_container_type & mapped_cont, const Allocator & alloc ) ;
(8) (C++23 起)
template < class Allocator >

flat_multimap ( std:: sorted_equivalent_t , const key_container_type & key_cont,
const mapped_container_type & mapped_cont,

const key_compare & comp, const Allocator & alloc ) ;
(9) (自 C++23 起)
explicit flat_multimap ( const key_compare & comp )
: c ( ) , compare ( comp ) { }
(10) (自 C++23 起)
template < class Allocator >
flat_multimap ( const key_compare & comp, const Allocator & alloc ) ;
(11) (C++23 起)
template < class Allocator >
explicit flat_multimap ( const Allocator & alloc ) ;
(12) (C++23 起)
template < class InputIter >

flat_multimap ( InputIter first, InputIter last,
const key_compare & comp = key_compare ( ) )

: c ( ) , compare ( comp ) ;
(13) (自 C++23 起)
template < class InputIter, class Allocator >

flat_multimap ( InputIter first, InputIter last,

const key_compare & comp, const Allocator & alloc ) ;
(14) (C++23 起)
template < class InputIter, class Allocator >
flat_multimap ( InputIter first, InputIter last, const Allocator & alloc ) ;
(15) (自 C++23 起)
template < container-compatible-range < value_type > R >

flat_multimap ( std:: from_range_t , R && rg, const key_compare & comp )

: flat_multimap ( comp ) ;
(16) (自 C++23 起)
template < container-compatible-range < value_type > R >

flat_multimap ( std:: from_range_t fr, R && rg )

: flat_multimap ( fr, std:: forward < R > ( rg ) , key_compare ( ) ) { }
(17) (自 C++23 起)
template < container-compatible-range < value_type > R, class Allocator >
flat_multimap ( std:: from_range_t , R && rg, const Allocator & alloc ) ;
(18) (自 C++23 起)
template < container-compatible-range < value_type > R, class Allocator >

flat_multimap ( std:: from_range_t , R && rg, const key_compare & comp,

const Allocator & alloc ) ;
(19) (自 C++23 起)
template < class InputIter >

flat_multimap ( std:: sorted_equivalent_t s, InputIter first, InputIter last,
const key_compare & comp = key_compare ( ) )

: c ( ) , compare ( comp ) ;
(20) (自 C++23 起)
template < class InputIter, class Allocator >

flat_multimap ( std:: sorted_equivalent_t s, InputIter first, InputIter last,

const key_compare & comp, const Allocator & alloc ) ;
(21) (自 C++23 起)
template < class InputIter, class Allocator >

flat_multimap ( std:: sorted_equivalent_t s, InputIter first, InputIter last,

const Allocator & alloc ) ;
(22) (自 C++23 起)
flat_multimap ( std:: initializer_list < value_type > init,

const key_compare & comp = key_compare ( ) )

: flat_multimap ( init. begin ( ) , init. end ( ) , comp ) { }
(23) (自 C++23 起)
template < class Allocator >

flat_multimap ( std:: initializer_list < value_type > init, const key_compare & comp,

const Allocator & alloc ) ;
(24) (自 C++23 起)
template < class Allocator >
flat_multimap ( std:: initializer_list < value_type > init, const Allocator & alloc ) ;
(25) (自 C++23 起)
flat_multimap ( std:: sorted_equivalent_t s, std:: initializer_list < value_type > init,

const key_compare & comp = key_compare ( ) )

: flat_multimap ( s, init. begin ( ) , init. end ( ) , comp ) { }
(26) (自 C++23 起)
template < class Allocator >

flat_multimap ( std:: sorted_equivalent_t s, std:: initializer_list < value_type > init,

const key_compare & comp, const Allocator & alloc ) ;
(27) (自 C++23 起)
template < class Allocator >

flat_multimap ( std:: sorted_equivalent_t s, std:: initializer_list < value_type > init,

const Allocator & alloc ) ;
(28) (C++23 起)

从多种数据源构造新的容器适配器,并可选择使用用户提供的比较函数对象 comp 和/或分配器 alloc

1) 默认构造函数。构造一个空的容器适配器。
2) 一个 copy constructor 。构造 c 时复制 other. c 的内容,并构造 compare 时使用 other. compare 。 请参阅下方的 allocator usage note
3) 一个 move constructor 。使用移动语义构造容器适配器,其内容来自 other 。 参见下方的 allocator usage note
4) 首先,使用 std :: move ( key_cont ) 初始化 c.keys ,使用 std :: move ( mapped_cont ) 初始化 c.values ,并使用 comp 初始化 compare 。随后根据 value_comp() 对底层范围 [ begin ( ) , end ( ) ) 进行排序。
5) (4) 相同,等价于 flat_multimap ( key_cont, mapped_cont ) ; 。 详见下方 分配器使用说明
6) (4) ,等价于 flat_multimap ( key_cont, mapped_cont, comp ) ; 。 详见下方 分配器使用说明
7) 使用 std :: move ( key_cont ) 初始化 c.keys , 使用 std :: move ( mapped_cont ) 初始化 c.values , 并使用 comp 初始化 compare
8) (7) ,等价于 flat_multimap ( s, key_cont, mapped_cont ) ; 。 参见下方 分配器使用说明
9) (7) 相同,等价于 flat_multimap ( s, key_cont, mapped_cont, comp ) ; 。 详见下方 分配器使用说明
10) 构造一个空的容器适配器。
11,12) 构造一个空的容器适配器。 详见下方 allocator usage note 说明。
13) 构造容器适配器,其内容为范围 [ first , last ) 中的元素,等价于 insert ( first, last ) ;
14,15) (13) 相同。 参见下方的 分配器使用说明
16) 构造容器适配器,其内容来自范围 rg 。首先使用 (10) 作为 委托构造函数 ,然后初始化 c rg 的内容,方式类似于 insert_range ( std:: forward < R > ( rg ) ) ;
17) (16) 相同,但将其用作 delegating constructor
18,19) (16) 相同。 参见下方的 分配器使用说明
20) 构造底层容器,以范围 [ first , last ) 的内容进行初始化,如同通过 insert ( first, last ) 操作实现。
21,22) (20) 相同。 参见下方的 分配器使用说明
23) 一个 初始化列表构造函数 。使用初始化列表 init 的内容构造底层容器,通过 (13) 作为 委托构造函数 实现。
24,25) (23) 相同。 参见下方的 分配器使用说明
26) 一个 initializer-list constructor 。使用初始化列表 init 的内容构造底层容器,通过 (20) 作为 delegating constructor 进行构造。
27,28) 保存方式同 (26) 。 参见下方 分配器使用说明

关于重载 (13-15,20-22) 的说明:如果 [ first , last ) 不是 有效范围 ,则行为未定义。

目录

分配器使用说明

构造函数 (2,3,5,6,8,9,11,12,14,15,17,19,21,22,24,25,27,28) 与对应的非分配器构造函数等效,区别在于底层容器 c.keys c.values 是通过 使用分配器构造 方式构建的。 这些重载仅当 std:: uses_allocator_v < container_type, Allocator > true 时参与重载决议。

参数

key_cont - 用作初始化底层键容器的源容器
mapped_cont - 用作初始化底层值容器的源容器
other - 用作源的另一 flat_multimap ,用于初始化底层容器的元素
alloc - 用于底层容器所有内存分配的分配器
comp - 用于所有键比较的函数对象
first, last - 定义待复制元素源 范围 的迭代器对
init - 用于初始化底层容器元素的初始化列表
rg - 一个 容器兼容范围 (即元素可转换为 value_type input_range ),用作初始化底层容器的源
fr - 一个 消歧义标签 ,指示应对包含的成员进行范围构造
s - 一个 消歧义标签 ,指示输入序列已按 value_comp() 排序
类型要求
-
InputIt 必须满足 LegacyInputIterator 的要求
-
Compare 必须满足 Compare 的要求
-
Allocator 必须满足 Allocator 的要求

复杂度

1) 常量。
2) 大小与 other 呈线性关系。
3) 与所包装容器的对应移动构造函数相同,即时间复杂度为常数阶或与 cont 的规模成线性关系。
4-6) cont 已按 value_comp() 排序,则与 N 呈线性关系;否则为 𝓞(N·log(N)) ,其中 N 表示本次调用前 key_cont. size ( ) 的值。
7-9) 与所包装容器的对应移动构造函数相同,即时间复杂度为常数或与 cont 的大小成线性关系。
10-12) 常量。
13-15) 时间复杂度为 N 的线性阶——当输入范围 [ first , last ) 已按 value_comp() 排序时;否则为 𝓞(N·log(N)) ,其中 N 表示本次调用前 key_cont. size ( ) 的值。
16-19) 若输入范围 rg 已按 value_comp() 排序,则时间复杂度为 N 的线性阶;否则为 𝓞(N·log(N)) ,其中 N 表示本次调用前 key_cont. size ( ) 的值。
20-22) [ first , last ) 的大小成线性关系。
23-25) 时间复杂度为 N 的线性阶,当 init 中的元素已按 value_comp() 排序时;否则为 𝓞(N·log(N)) ,其中 N 表示本次调用前 key_cont. size ( ) 的值。
26-28) init 的大小成线性关系。

异常

Allocator::allocate 的调用可能抛出异常。

注释

在容器移动构造(重载 ( 3 ) 完成)后,指向 other 的引用、指针和迭代器(除尾后迭代器外)仍然有效,但所引用的元素现在位于 * this 中。当前标准通过 [container.reqmts]/67 中的总体声明提供此保证,同时正在通过 LWG 问题 2321 考虑提供更直接的保证。

示例

另请参阅

为容器适配器赋值
(公开成员函数)