std::map
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <map> で定義
|
||
template< class Key, class T, class Compare = std::less<Key>, class Allocator = std::allocator<std::pair<const Key, T> > > class map; |
(1) | |
namespace pmr { template <class Key, class T, class Compare = std::less<Key>> using map = std::map<Key, T, Compare, std::pmr::polymorphic_allocator<std::pair<const Key,T>>> } |
(2) | (C++17以上) |
std::map は一意なキーを持つキー値ペアを格納するソートされた連想コンテナです。 キーは比較関数 Compare を使用してソートされます。 検索、削除、挿入の操作の計算量は対数時間です。 map は通常赤黒木として実装されます。
標準ライブラリが Compare 要件を使用する場所ではすべて、一意性は同等関係を使用して決定されます。 不正確な言葉で言うと、2つのオブジェクト a と b は、どちらがどちらより小さいわけでもない (!comp(a, b) && !comp(b, a)) 場合に等しいとみなされます。
std::map は Container, AllocatorAwareContainer, AssociativeContainer, ReversibleContainer の要件を満たします。
メンバ型
| メンバ型 | 定義 | ||||
key_type
|
Key
| ||||
mapped_type
|
T
| ||||
value_type
|
std::pair<const Key, T>
| ||||
size_type
|
符号なし整数型 (通常 std::size_t) | ||||
difference_type
|
符号付き整数型 (通常 std::ptrdiff_t) | ||||
key_compare
|
Compare
| ||||
allocator_type
|
Allocator
| ||||
reference
|
| ||||
const_reference
|
| ||||
pointer
|
| ||||
const_pointer
|
| ||||
iterator
|