名前空間
変種

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つのオブジェクト ab は、どちらがどちらより小さいわけでもない (!comp(a, b) && !comp(b, a)) 場合に等しいとみなされます。

std::mapContainer, AllocatorAwareContainer, AssociativeContainer, ReversibleContainer の要件を満たします。

メンバ型

メンバ型 定義
key_type Key [edit]
mapped_type T [edit]
value_type std::pair<const Key, T> [edit]
size_type 符号なし整数型 (通常 std::size_t) [edit]
difference_type 符号付き整数型 (通常 std::ptrdiff_t) [edit]
key_compare Compare [edit]
allocator_type Allocator [edit]
reference
Allocator::reference (C++11未満)
value_type& (C++11以上)
[edit]
const_reference
Allocator::const_reference (C++11未満)
const value_type& (C++11以上)
[edit]
pointer
Allocator::pointer (C++11未満)
std::allocator_traits<Allocator>::pointer (C++11以上)
[edit]
const_pointer
Allocator::const_pointer (C++11未満)
std::allocator_traits<Allocator>::const_pointer (C++11以上)
[edit]
iterator