AssociativeContainer
C++概念:关联容器
安AssociativeContainer
是有序的Container
它提供基于键的对象快速查找。
所需
传说
*。
X容器型
X型值
节点句柄与X兼容的Y型的A2值
B可能是X型的Const值
U任意变量名
阿[医]当X支持唯一键时,X类型的Uniq值
阿[医]当X支持多个键时,X类型的EQ值
阿[医]当类型X::Key时,X类型的可能Const值[医]比较::IS[医]透明存在
表示有效范围的i,j InputIterator,并引用隐式可转换为X::value的元素[医]类型
p是一个有效的Const迭代器。
q一个有效的可取消引用的Const迭代器到
r一个有效的可取消引用的迭代器到
中表示有效范围的Q1,Q2迭代器。
ILI类型为std::初始化器的对象[医]列表<值[医]类型>
TA型值::值[医]类型
KA型值X::Key[医]类型
Ca可能满足X::Key类型的值[医]比较
KLA值,使得a相对于c%28r、kl%29被划分,而r的键值e和e在
Ku A值,使得a相对于%21c%28 ku,r%29被划分
对于c%28r,ke%29和%21c%28 ke,r%29,c%28r,ke%29,表示%21c%28ke,r%29
X或STD::分配器使用的存储分配器[医]类型<X::值[医]类型>
一种可转换为A的M分配器
NHA型非参数X::节点[医]类型
expression | return type | pre/requirements | post/effects | complexity |
---|---|---|---|---|
X::key_type | Key | Key is Destructible | | compile time |
X::key_compare | Compare | | | compile time |
X::value_compare | a type satisfying BinaryPredicate | key_compare for std::set and std::multiset; an ordering relation over Key for std::map and std::multimap | | compile time |
X(c), X a(c | | key_compare is CopyConstructible | Construct an empty container using a copy of c as key_comp | constant |
X(), X a; | | key_compare is CopyConstructible | Construct an empty container using a Compare() as key_comp | constant |
X(i, j, c), X a(i, j, c | | key_compare is CopyConstructible and value_type is EmplaceConstructible into X from *i | Constructs an empty container using a copy of c as key_comp and inserts all elements from the range [i; j) | generally N log N, or N if [i, j) is sorted (where N is std::distance(i, j)) |
X(i, j), X a(i, j | | key_compare is CopyConstructible and value_type is EmplaceConstructible into X from *i | Constructs an empty container using a Compare() as key_comp and inserts all elements from the range [i; j) | generally N log N, or N if [i, j) is sorted according to value_comp() (where N is std::distance(i, j)) |
X(il | | Equivalent to X(il.begin(), il.end() | Equivalent to X(il.begin(), il.end() | |
a = il | X& | T is CopyInsertable into X and also CopyAssignable | Assign the range [il.begin(), il.end()) into a. Elements of a that were not assigned to are destroyed | generally N log N, or N if [il.begin(), il.end()) is sorted according to value_comp() (where N is il.size() + a.size()) |
a.key_comp() | X::key_compare | | The comparison object with which a was constructed is returned. | constant |
a.value_comp() | X::value_compare | | An object of type X::value_compare constructed out of the comparison object is returned. | constant |
联合容器X
那不是std::map
和std::multimap
此外,还支持表达式X
::map[医]类型,它的返回类型为T
,并要求T
成Destructible
,以及编译时的复杂性。
标准库中的联合收货人
set | collection of unique keys, sorted by keys (class template) |
---|---|
multiset | collection of keys, sorted by keys (class template) |
map | collection of key-value pairs, sorted by keys, keys are unique (class template) |
multimap | collection of key-value pairs, sorted by keys (class template) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。