std::flat_map<Key,T,Compare,KeyContainer,MappedContainer>:: flat_map
|
flat_map
(
)
: flat_map ( key_compare ( ) ) { } |
(1) | (自 C++23 起) |
|
template
<
class
Allocator
>
flat_map ( const flat_map & , const Allocator & alloc ) ; |
(2) | (自 C++23 起) |
|
template
<
class
Allocator
>
flat_map ( flat_map && , const Allocator & alloc ) ; |
(3) | (自 C++23 起) |
|
flat_map
(
key_container_type key_cont, mapped_container_type mapped_cont,
const key_compare & comp = key_compare ( ) ) ; |
(4) | (C++23 起) |
|
template
<
class
Allocator
>
flat_map
(
const
key_container_type
&
key_cont,
|
(5) | (自 C++23 起) |
|
template
<
class
Allocator
>
flat_map
(
const
key_container_type
&
key_cont,
|
(6) | (自 C++23 起) |
|
flat_map
(
std::
sorted_unique_t
, key_container_type key_cont,
mapped_container_type mapped_cont,
|
(7) | (C++23 起) |
|
template
<
class
Allocator
>
flat_map
(
std::
sorted_unique_t
,
const
key_container_type
&
key_cont,
|
(8) | (C++23 起) |
|
template
<
class
Allocator
>
flat_map
(
std::
sorted_unique_t
,
const
key_container_type
&
key_cont,
|
(9) | (自 C++23 起) |
|
explicit
flat_map
(
const
key_compare
&
comp
)
: c ( ) , compare ( comp ) { } |
(10) | (自 C++23 起) |
|
template
<
class
Allocator
>
flat_map ( const key_compare & comp, const Allocator & alloc ) ; |
(11) | (自 C++23 起) |
|
template
<
class
Allocator
>
explicit flat_map ( const Allocator & alloc ) ; |
(12) | (自 C++23 起) |
|
template
<
class
InputIter
>
flat_map
(
InputIter first, InputIter last,
|
(13) | (自 C++23 起) |
|
template
<
class
InputIter,
class
Allocator
>
flat_map
(
InputIter first, InputIter last,
|
(14) | (自 C++23 起) |
|
template
<
class
InputIter,
class
Allocator
>
flat_map ( InputIter first, InputIter last, const Allocator & alloc ) ; |
(15) | (自 C++23 起) |
|
template
<
container-compatible-range
<
value_type
>
R
>
flat_map
(
std::
from_range_t
, R
&&
rg,
const
key_compare
&
comp
)
|
(16) | (自 C++23 起) |
|
template
<
container-compatible-range
<
value_type
>
R
>
flat_map
(
std::
from_range_t
fr, R
&&
rg
)
|
(17) | (C++23 起) |
|
template
<
container-compatible-range
<
value_type
>
R,
class
Allocator
>
flat_map ( std:: from_range_t , R && rg, const Allocator & alloc ) ; |
(18) | (自 C++23 起) |
|
template
<
container-compatible-range
<
value_type
>
R,
class
Allocator
>
flat_map
(
std::
from_range_t
, R
&&
rg,
const
key_compare
&
comp,
|
(19) | (自 C++23 起) |
|
template
<
class
InputIter
>
flat_map
(
std::
sorted_unique_t
s, InputIter first, InputIter last,
|
(20) | (自 C++23 起) |
|
template
<
class
InputIter,
class
Allocator
>
flat_map
(
std::
sorted_unique_t
s, InputIter first, InputIter last,
|
(21) | (自 C++23 起) |
|
template
<
class
InputIter,
class
Allocator
>
flat_map
(
std::
sorted_unique_t
s, InputIter first, InputIter last,
|
(22) | (C++23 起) |
|
flat_map
(
std::
initializer_list
<
value_type
>
init,
const
key_compare
&
comp
=
key_compare
(
)
)
|
(23) | (自 C++23 起) |
|
template
<
class
Allocator
>
flat_map
(
std::
initializer_list
<
value_type
>
init,
const
key_compare
&
comp,
|
(24) | (自 C++23 起) |
|
template
<
class
Allocator
>
flat_map ( std:: initializer_list < value_type > init, const Allocator & alloc ) ; |
(25) | (C++23 起) |
|
flat_map
(
std::
sorted_unique_t
s,
std::
initializer_list
<
value_type
>
init,
const
key_compare
&
comp
=
key_compare
(
)
)
|
(26) | (自 C++23 起) |
|
template
<
class
Allocator
>
flat_map
(
std::
sorted_unique_t
s,
std::
initializer_list
<
value_type
>
init,
|
(27) | (自 C++23 起) |
|
template
<
class
Allocator
>
flat_map
(
std::
sorted_unique_t
s,
std::
initializer_list
<
value_type
>
init,
|
(28) | (自 C++23 起) |
从多种数据源构造新的容器适配器,并可选择使用用户提供的比较函数对象 comp 和/或分配器 alloc 。
c
时使用
other.
c
内容的副本,并构造
compare
时使用
other.
compare
。
请参阅下方的
allocator usage note
。
c.keys
,使用
std
::
move
(
mapped_cont
)
初始化
c.values
,并使用
comp
初始化
compare
。随后根据
value_comp()
对底层范围
[
begin
(
)
,
end
(
)
)
进行排序。最后,按以下方式擦除重复元素:
auto zv = views:: zip ( c. keys , c. values ) ;
auto it = ranges:: unique ( zv, key_equiv ( compare ) ) . begin ( ) ;
auto dist = distance ( zv. begin ( ) , it ) ;
c. keys . erase ( c. keys . begin ( ) + dist, c. keys . end ( ) ) ;
c. values . erase ( c. values . begin ( ) + dist, c. values . end ( ) ) ; 。
c.keys
,
使用
std
::
move
(
mapped_cont
)
初始化
c.values
,
并使用
comp
初始化
compare
。
[
first
,
last
)
中的元素,等价于
insert
(
first, last
)
;
。
c
为
rg
的内容,具体方式为
insert_range
(
std::
forward
<
R
>
(
rg
)
)
;
。
[
first
,
last
)
的内容,如同通过
insert
(
first, last
)
操作实现。
关于重载
(13-15,20-22)
的说明:如果
[
first
,
last
)
不是
有效范围
,则行为未定义。
Note for overloads (4-6,13-19,23-25) : If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted (pending LWG2844 ).
目录分配器使用说明
构造函数
(2,3,5,6,8,9,11,12,14,15,17,19,21,22,24,25,27,28)
与对应的非分配器构造函数等效,区别在于底层容器
参数
复杂度
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)
若输入范围
[
first
,
last
)
已按
value_comp()
排序,则时间复杂度为与
N
呈线性关系;否则为
𝓞(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)
若
init
的元素已按
value_comp()
排序,则时间复杂度为
N
的线性阶;否则为
𝓞(N·log(N))
,其中
N
表示本次调用前
key_cont.
size
(
)
的值。
26-28)
与
init
的大小呈线性关系。
异常处理
对
注意在容器移动构造(重载 (3))之后,原先引用 示例
另请参阅
| ||||||||||||||||||||||||||||||||||||||||||||||