名前空間
変種
操作

std::map

提供: cppreference.com
< cpp‎ | container
 
 
 
 
ヘッダ <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 LegacyBidirectionalIterator [edit]
const_iterator const LegacyBidirectionalIterator [edit]
reverse_iterator std::reverse_iterator<iterator> [edit]
const_reverse_iterator std::reverse_iterator<const_iterator> [edit]
node_type
(C++17以上)
コンテナノードを表すノードハンドルの特殊化 [edit]
insert_return_type
(C++17以上)
node_type を挿入した結果を表す型。 テンプレート引数 iterator および node_type でインスタンス化された
template <class Iter, class NodeType> struct /*unspecified*/ {
    Iter     position;
    bool     inserted;
    NodeType node;
};
の特殊化 [edit]

[編集] メンバクラス

value_type 型のオブジェクトを比較します
(クラス) [edit]

[編集] メンバ関数

map を構築します
(パブリックメンバ関数) [edit]
map を破棄します
(パブリックメンバ関数) [edit]
コンテナに値を代入します
(パブリックメンバ関数) [edit]
関連付けられているアロケータを返します
(パブリックメンバ関数) [edit]
要素アクセス
(C++11)
境界チェック付きで指定された要素にアクセスします
(パブリックメンバ関数) [edit]
指定された要素にアクセスまたは挿入します
(パブリックメンバ関数) [edit]
イテレータ
先頭を指すイテレータを返します
(パブリックメンバ関数) [edit]
終端を指すイテレータを返します
(パブリックメンバ関数) [edit]
先頭を指す逆イテレータを返します
(パブリックメンバ関数) [edit]
終端を指す逆イテレータを返します
(パブリックメンバ関数) [edit]
容量
コンテナが空かどうか調べます
(パブリックメンバ関数) [edit]
要素数を返します
(パブリックメンバ関数) [edit]
可能な最大の要素数を返します
(パブリックメンバ関数) [edit]
変更
すべての要素を削除します
(パブリックメンバ関数) [edit]
要素またはノード (C++17以上)を挿入します
(パブリックメンバ関数) [edit]
要素を挿入します。 キーがすでに存在している場合は現在の要素に代入します
(パブリックメンバ関数) [edit]
(C++11)
要素をその場で構築します
(パブリックメンバ関数) [edit]
ヒントを使用して要素をその場で構築します
(パブリックメンバ関数) [edit]
キーが存在しなければその場で挿入します。 キーが存在している場合は何もしません
(パブリックメンバ関数) [edit]
要素を削除します
(パブリックメンバ関数) [edit]
(C++11)
内容を入れ替えます
(パブリックメンバ関数) [edit]
(C++17)
コンテナからノードを抽出します
(パブリックメンバ関数) [edit]
(C++17)
他のコンテナからノードを接合します
(パブリックメンバ関数) [edit]
検索
指定されたキーと一致する要素の数を返します
(パブリックメンバ関数) [edit]
指定されたキーを持つ要素を探します
(パブリックメンバ関数) [edit]
(C++20)
コンテナが指定されたキーを持つ要素を格納しているかどうか調べます
(パブリックメンバ関数) [edit]
指定されたキーに一致する要素の範囲を返します
(パブリックメンバ関数) [edit]
指定されたキーより小さくない最初の要素を指すイテレータを返します
(パブリックメンバ関数) [edit]
指定されたキーより大きい最初の要素を指すイテレータを返します
(パブリックメンバ関数) [edit]
観察
キーを比較する関数を返します
(パブリックメンバ関数) [edit]
value_type 型のオブジェクト内のキーを比較する関数を返します
(パブリックメンバ関数) [edit]

[編集] 非メンバ関数

(C++20で削除)(C++20で削除)(C++20で削除)(C++20で削除)(C++20で削除)(C++20)
map 内の値を辞書的に比較します
(関数テンプレート) [edit]
std::swap アルゴリズムの特殊化
(関数テンプレート) [edit]
特定の基準を満たすすべての要素を削除します
(関数テンプレート) [edit]

[編集] 推定ガイド(C++17以上)