Share via


multimap (STL/CLR)

このテンプレート クラスは、双方向にアクセスできる可変長の要素シーケンスを制御するオブジェクトを表します。 multimap コンテナーを使って、要素シーケンスを、(ほぼ) バランスのとれた順序付きノード ツリーとして管理します。各ノードには 1 つの要素が格納されます。 要素は、シーケンスを順序付けるためのキーと、マップされた値で構成されていて、これらは一緒に移動します。

以降の説明では、GValue は次と同じです。

Microsoft::VisualC::StlClr::GenericPair<GKey, GMapped>

どこで:

GKey は、後者が ref 型でない限り同じです Key が、その場合は Key^

GMapped は、後者が ref 型でない限り同じです Mapped が、その場合は Mapped^

構文

template<typename Key,
    typename Mapped>
    ref class multimap
        :   public
        System::ICloneable,
        System::Collections::IEnumerable,
        System::Collections::ICollection,
        System::Collections::Generic::IEnumerable<GValue>,
        System::Collections::Generic::ICollection<GValue>,
        System::Collections::Generic::IList<GValue>,
        Microsoft::VisualC::StlClr::ITree<Gkey, GValue>
    { ..... };

パラメーター

Key
制御シーケンス内の要素のキー コンポーネントの型。

Mapped
制御シーケンス内の要素の他のコンポーネントの型。

必要条件

ヘッダー:<cliext/map>

名前空間cliext:

宣言

型定義 説明
multimap::const_iterator 被制御シーケンスの定数反復子の型です。
multimap::const_reference 要素への定数参照の型です。
multimap::const_reverse_iterator 被制御シーケンスの定数反転反復子の型です。
multimap::difference_type 2 つの要素間の距離を表す (場合によっては符号付きの) 型です。
multimap::generic_container コンテナーのジェネリック インターフェイスの型です。
multimap::generic_iterator コンテナーのジェネリック インターフェイスの反復子の型です。
multimap::generic_reverse_iterator コンテナーのジェネリック インターフェイスの反転反復子の型です。
multimap::generic_value コンテナーのジェネリック インターフェイスの要素の型です。
multimap::iterator 被制御シーケンスの反復子の型です。
multimap::key_compare 2 つのキーの順序付けデリゲートです。
multimap::key_type 順序付けキーの型です。
multimap::mapped_type 各キーに関連付けられた、マップされた値の型です。
multimap::reference 要素への参照の型です。
multimap::reverse_iterator 被制御シーケンスの反転反復子の型です。
multimap::size_type 2 つの要素間の距離を表す (負でない) 型です。
multimap::value_compare 2 つの要素値の順序付けデリゲートです。
multimap::value_type 要素の型。
メンバー関数 説明
multimap::begin 被制御シーケンスの先頭を指定します。
multimap::clear すべての要素を削除します。
multimap::count 指定したキーに一致する要素をカウントします。
multimap::empty 要素が存在しないかどうかをテストします。
multimap::end 被制御シーケンスの末尾を指定します。
multimap::equal_range 指定したキーに一致する範囲を検索します。
multimap::erase 指定した位置にある要素を削除します。
multimap::find 指定したキーに一致する要素を検索します。
multimap::insert 要素を追加します。
multimap::key_comp 2 つのキーの順序付けデリゲートをコピーします。
multimap::lower_bound 指定したキーに一致する範囲の先頭を検索します。
multimap::make_value 値オブジェクトを構築します。
multimap::multimap コンテナー オブジェクトを構築します。
multimap::rbegin 反転被制御シーケンスの先頭を指定します。
multimap::rend 反転被制御シーケンスの末尾を指定します。
multimap::size 要素の数をカウントします。
multimap::swap 2 つのコンテナーのコンテンツを交換します。
multimap::to_array 被制御シーケンスを新しい配列にコピーします。
multimap::upper_bound 指定したキーに一致する範囲の末尾を検索します。
multimap::value_comp 2 つの要素値の順序付けデリゲートをコピーします。
Operator 説明
multimap::operator= 被制御シーケンスを置き換えます。
operator!= (multimap) オブジェクトが別multimapmultimapオブジェクトと等しくないかどうかを判断します。
operator< (multimap) multimap オブジェクトが別の multimap オブジェクトより小さいかどうかを確認します。
operator<= (multimap) multimap オブジェクトが別の multimap オブジェクト以下かどうかを判断します。
operator== (multimap) multimap オブジェクトが別の multimap オブジェクトと等しいかどうかを判断します。
operator> (multimap) multimap オブジェクトが別の multimap オブジェクトより大きいかどうかを判断します。
operator>= (multimap) multimap オブジェクトが別の multimap オブジェクト以上かどうかを判断します。

インターフェイス

インターフェイス 説明
ICloneable オブジェクトを複製します。
IEnumerable 要素をシーケンス処理します。
ICollection 要素のグループを維持します。
IEnumerable<T> 型指定された要素をシーケンス処理します。
ICollection<T> 型指定された要素のグループを維持します。
ITree<Key, Value> ジェネリック コンテナーを維持します。

解説

このオブジェクトは、個々のノードとして制御するシーケンスのストレージを割り当てたり解放したりします。 ノードのコンテンツを別のノードにコピーするのではなく、ノード間のリンクを変更することにより、順序付けを維持した状態で (ほぼ) バランスの取れたツリーに要素を挿入します。 つまり、残りの要素に影響を与えずに、要素を自由に挿入および削除できます。

オブジェクトは、型の格納されたデリゲート オブジェクトを呼び出すことによって、制御するシーケンスを並べ替えます multimap::key_compare。 multimap の構築時に、格納されているデリゲート オブジェクトを指定できます。デリゲート オブジェクトを指定しない場合、既定値は比較 operator<(key_type, key_type) です。 この格納されているオブジェクトにアクセスするには、メンバー関数 multimap::key_compを呼び出します。

このようなデリゲート オブジェクトは、型 multimap::key_typeのキーに厳密な弱い順序を課す必要があります。 つまり、任意の 2 つのキー XY については、次のようになります。

key_comp()(X, Y) は、すべての呼び出しで同じブール値の結果を返します。

key_comp()(X, Y) が true の場合は、key_comp()(Y, X) が false である必要があります。

key_comp()(X, Y) が true の場合、XY の前に順序付けられるものとされます。

!key_comp()(X, Y) && !key_comp()(Y, X) が true の場合、XY の順序付けが等しくなります。

被制御シーケンスで要素 XY の前に指定されている場合、key_comp()(Y, X) は false になります (既定のデリゲート オブジェクトの場合、キーの値が減少することはありません)。テンプレート クラス マップ (STL/CLR) とは異なり、テンプレート クラス multimap のオブジェクトでは、すべての要素のキーが一意である必要はありません。 (2 つ以上のキーの順序付けを等しくすることができます)。

各要素には、個別のキーとマップされた値が含まれます。 シーケンスは、任意の要素の検索、挿入、および削除を対数時間で許可する方法で表されます。 つまり、演算の数は、シーケンス内の要素数の対数に比例します。 さらに、要素を挿入すると反復子が無効になり、要素を削除すると、削除された要素を指す反復子のみが無効になります。

A は multimap 双方向反復子をサポートしています。つまり、被制御シーケンス内の要素を指定する反復子を指定すると、隣接する要素にステップ インできます。 特殊なヘッド ノードは、によって end()返される反復子に対応します。 この反復子をデクリメントすると、被制御シーケンス内の最後の要素 (存在する場合) に到達できます。 反復子を multimap インクリメントしてヘッド ノードに到達すると、等しい end()値と比較されます。 ただし、返される end()反復子を逆参照することはできません。

数値の位置を指定して要素を multimap 直接参照することはできません。 これにはランダム アクセス反復子が必要です。

反復子は multimap 、関連付けられた multimap ノードへのハンドルを格納し、関連付けられたコンテナーへのハンドルを格納します。 反復子は、関連付けられているコンテナー オブジェクトでのみ使用できます。 multimap反復子メイン関連付けられたmultimapノードが何らかのマルチマップに関連付けられている限り有効です。 さらに、有効な反復子は逆参照可能です。 指定した要素値にアクセスしたり変更したりするために使用できます(等しくない end()限り)。

要素を消去または削除すると、格納されている値のデストラクターが呼び出されます。 コンテナーを破棄すると、すべての要素が消去されます。 したがって、要素型が ref クラスのコンテナーでは、コンテナーよりも有効期間が長い要素はありません。 ただし、ハンドルのコンテナーでは、その要素は破棄されません。

メンバー

multimap::begin

被制御シーケンスの先頭を指定します。

構文

iterator begin();

解説

このメンバー関数は、被制御シーケンスの最初の要素 (または空のシーケンスの末尾の次の位置) を指定する双方向反復子を返します。 これを使用して被制御シーケンスの先頭を指定する反復子を current 取得しますが、被制御シーケンスの長さが変わると状態が変わる可能性があります。

// cliext_multimap_begin.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect first two items
    Mymultimap::iterator it = c1.begin();
    System::Console::WriteLine("*begin() = [{0} {1}]",
        it->first, it->second);
    ++it;
    System::Console::WriteLine("*++begin() = [{0} {1}]",
        it->first, it->second);
    return (0);
    }
[a 1] [b 2] [c 3]
*begin() = [a 1]
*++begin() = [b 2]

multimap::clear

すべての要素を削除します。

構文

void clear();

解説

メンバー関数は、erase(begin(), end()) を効果的に呼び出します。 被制御シーケンスが空であることを確実にするために使います。

// cliext_multimap_clear.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // clear the container and reinspect
    c1.clear();
    System::Console::WriteLine("size() = {0}", c1.size());

    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));

    // display contents " [a 1] [b 2]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    c1.clear();
    System::Console::WriteLine("size() = {0}", c1.size());
    return (0);
    }
[a 1] [b 2] [c 3]
size() = 0
[a 1] [b 2]
size() = 0

multimap::const_iterator

被制御シーケンスの定数反復子の型です。

構文

typedef T2 const_iterator;

解説

この型は、被制御シーケンスの定数双方向反復子として使用できる未指定の T2 型のオブジェクトを表します。

// cliext_multimap_const_iterator.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    Mymultimap::const_iterator cit = c1.begin();
    for (; cit != c1.end(); ++cit)
        System::Console::Write("[{0} {1}] ", cit->first, cit->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]

multimap::const_reference

要素への定数参照の型です。

構文

typedef value_type% const_reference;

解説

この型は、要素への定数参照を表します。

// cliext_multimap_const_reference.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    Mymultimap::const_iterator cit = c1.begin();
    for (; cit != c1.end(); ++cit)
        {   // get a const reference to an element
        Mymultimap::const_reference cref = *cit;
        System::Console::Write("[{0} {1}] ", cref->first, cref->second);
        }
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]

multimap::const_reverse_iterator

被制御シーケンスの定数反転反復子の型です。

構文

typedef T4 const_reverse_iterator;

解説

この型は、被制御シーケンスの定数反転反復子として使用できる未指定の T4 型のオブジェクトを表します。

// cliext_multimap_const_reverse_iterator.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]" reversed
    Mymultimap::const_reverse_iterator crit = c1.rbegin();
    for (; crit != c1.rend(); ++crit)
        System::Console::Write("[{0} {1}] ", crit->first, crit->second);
    System::Console::WriteLine();
    return (0);
    }
[c 3] [b 2] [a 1]

multimap::count

指定したキーに一致する要素の数を検索します。

構文

size_type count(key_type key);

パラメーター

key
検索対象のキー値。

解説

このメンバー関数は、次の値と同等の順序を持つ、制御シーケンス内の要素の数を key返します。 これを使用して、指定したキーと一致する、現在、制御シーケンス内の要素の数を決定します。

// cliext_multimap_count.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("count(L'A') = {0}", c1.count(L'A'));
    System::Console::WriteLine("count(L'b') = {0}", c1.count(L'b'));
    System::Console::WriteLine("count(L'C') = {0}", c1.count(L'C'));
    return (0);
    }
[a 1] [b 2] [c 3]
count(L'A') = 0
count(L'b') = 1
count(L'C') = 0

multimap::difference_type

2 つの要素間の符号付きの距離を表す型です。

構文

typedef int difference_type;

解説

この型は、場合によっては負の要素数を表します。

// cliext_multimap_difference_type.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // compute positive difference
    Mymultimap::difference_type diff = 0;
    for (Mymultimap::iterator it = c1.begin(); it != c1.end(); ++it)
        ++diff;
    System::Console::WriteLine("end()-begin() = {0}", diff);

    // compute negative difference
    diff = 0;
    for (Mymultimap::iterator it = c1.end(); it != c1.begin(); --it)
        --diff;
    System::Console::WriteLine("begin()-end() = {0}", diff);
    return (0);
    }
[a 1] [b 2] [c 3]
end()-begin() = 3
begin()-end() = -3

multimap::empty

要素が存在しないかどうかをテストします。

構文

bool empty();

解説

このメンバー関数は、被制御シーケンスが空の場合に true を返します。 これは size() == 0 と同じです。 これを使用して、空かどうかを multimap テストします。

// cliext_multimap_empty.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    System::Console::WriteLine("size() = {0}", c1.size());
    System::Console::WriteLine("empty() = {0}", c1.empty());

    // clear the container and reinspect
    c1.clear();
    System::Console::WriteLine("size() = {0}", c1.size());
    System::Console::WriteLine("empty() = {0}", c1.empty());
    return (0);
    }
[a 1] [b 2] [c 3]
size() = 3
empty() = False
size() = 0
empty() = True

multimap::end

被制御シーケンスの末尾を指定します。

構文

iterator end();

解説

このメンバー関数は、被制御シーケンスの末尾を越えたところを示す双方向反復子を返します。 これを使用して、被制御シーケンスの末尾を指定する反復子を取得します。その状態は、制御シーケンスの長さが変更されても変わりません。

// cliext_multimap_end.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect last two items
    Mymultimap::iterator it = c1.end();
    --it;
    --it;
    System::Console::WriteLine("*-- --end() = [{0} {1}]",
        it->first, it->second);
    ++it;
    System::Console::WriteLine("*--end() = [{0} {1}]",
        it->first, it->second);
    return (0);
    }
[a 1] [b 2] [c 3]
*-- --end() = [b 2]
*--end() = [c 3]

multimap::equal_range

指定したキーに一致する範囲を検索します。

構文

pair_iter_iter equal_range(key_type key);

パラメーター

key
検索対象のキー値。

解説

このメソッドは、 pair_iter_iter(lower_bound(key), upper_bound(key))反復子のペアを返します。 指定したキーに一致する、被制御シーケンス内の現在の要素の範囲を特定するために使います。

// cliext_multimap_equal_range.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
typedef Mymultimap::pair_iter_iter Pairii;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // display results of failed search
    Pairii pair1 = c1.equal_range(L'x');
    System::Console::WriteLine("equal_range(L'x') empty = {0}",
        pair1.first == pair1.second);

    // display results of successful search
    pair1 = c1.equal_range(L'b');
    for (; pair1.first != pair1.second; ++pair1.first)
        System::Console::Write("[{0} {1}] ",
            pair1.first->first, pair1.first->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
equal_range(L'x') empty = True
[b 2]

multimap::erase

指定した位置にある要素を削除します。

構文

iterator erase(iterator where);
iterator erase(iterator first, iterator last);
bool erase(key_type key)

パラメーター

first
消去する範囲の先頭。

key
消去するキー値。

last
消去する範囲の末尾。

where
消去する要素。

解説

最初のメンバー関数は、指定された被制御シーケンスの要素を削除し、削除されたwhere要素を超えて、またはend()そのような要素が存在しない場合にメイン最初の要素を指定する反復子を返します。 1 つの要素を削除する場合に使います。

2 番目のメンバー関数は、範囲 [first, ), 内の被制御シーケンスの要素を削除し、last削除された要素を超えてメイン最初の要素を指定する反復子を返します。またはend()、そのような要素が存在しない場合。 0 個以上の連続する要素を削除する場合に、これを使用します。

3 番目のメンバー関数は、キーの順序 keyが同等の制御シーケンスの要素を削除し、削除された要素の数を返します。 指定したキーに一致するすべての要素を削除してカウントする場合に、これを使用します。

各要素の消去には、被制御シーケンス内の要素数の対数に比例した時間が必要です。

// cliext_multimap_erase.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    cliext::multimap<wchar_t, int> c1;
    c1.insert(cliext::multimap<wchar_t, int>::make_value(L'a', 1));
    c1.insert(cliext::multimap<wchar_t, int>::make_value(L'b', 2));
    c1.insert(cliext::multimap<wchar_t, int>::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (cliext::multimap<wchar_t, int>::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // erase an element and reinspect
    cliext::multimap<wchar_t, int>::iterator it =
        c1.erase(c1.begin());
    System::Console::WriteLine("erase(begin()) = [{0} {1}]",
        it->first, it->second);

    // add elements and display " b c d e"
    c1.insert(cliext::multimap<wchar_t, int>::make_value(L'd', 4));
    c1.insert(cliext::multimap<wchar_t, int>::make_value(L'e', 5));
    for each (cliext::multimap<wchar_t, int>::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // erase all but end
    it = c1.end();
    it = c1.erase(c1.begin(), --it);
    System::Console::WriteLine("erase(begin(), end()-1) = [{0} {1}]",
        it->first, it->second);
    System::Console::WriteLine("size() = {0}", c1.size());

    // erase end
    System::Console::WriteLine("erase(L'x') = {0}", c1.erase(L'x'));
    System::Console::WriteLine("erase(L'e') = {0}", c1.erase(L'e'));
    return (0);
    }
[a 1] [b 2] [c 3]
erase(begin()) = [b 2]
[b 2] [c 3] [d 4] [e 5]
erase(begin(), end()-1) = [e 5]
size() = 1
erase(L'x') = 0
erase(L'e') = 1

multimap::find

指定したキーに一致する要素を検索します。

構文

iterator find(key_type key);

パラメーター

key
検索対象のキー値。

解説

被制御シーケンス内の少なくとも 1 つの要素の順序 keyが等しい場合、メンバー関数はそれらの要素のいずれかを指定する反復子を返します。それ以外の場合は返しますend()。 被制御シーケンス内の指定したキーに一致する現在の要素を検索する場合に使います。

// cliext_multimap_find.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("find {0} = {1}",
        L'A', c1.find(L'A') != c1.end());

    Mymultimap::iterator it = c1.find(L'b');
    System::Console::WriteLine("find {0} = [{1} {2}]",
        L'b', it->first, it->second);

    System::Console::WriteLine("find {0} = {1}",
        L'C', c1.find(L'C') != c1.end());
    return (0);
    }
[a 1] [b 2] [c 3]
find A = False
find b = [b 2]
find C = False

multimap::generic_container

コンテナーのジェネリック インターフェイスの型です。

構文

typedef Microsoft::VisualC::StlClr::
    ITree<GKey, GValue>
    generic_container;

解説

この型は、このテンプレート コンテナー クラスのジェネリック インターフェイスを表します。

// cliext_multimap_generic_container.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct a generic container
    Mymultimap::generic_container^ gc1 = %c1;
    for each (Mymultimap::value_type elem in gc1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // modify generic and display original
    gc1->insert(Mymultimap::make_value(L'd', 4));
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // modify original and display generic
    c1.insert(Mymultimap::make_value(L'e', 5));
    for each (Mymultimap::value_type elem in gc1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3] [d 4]
[a 1] [b 2] [c 3] [d 4] [e 5]

multimap::generic_iterator

コンテナーのジェネリック インターフェイスで使用する反復子の型です。

構文

typedef Microsoft::VisualC::StlClr::Generic::
    ContainerBidirectionalIterator<generic_value>
    generic_iterator;

解説

この型は、このテンプレート コンテナー クラスのジェネリック インターフェイスで使用できるジェネリック反復子を表します。

// cliext_multimap_generic_iterator.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct a generic container
    Mymultimap::generic_container^ gc1 = %c1;
    for each (Mymultimap::value_type elem in gc1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // get an element and display it
    Mymultimap::generic_iterator gcit = gc1->begin();
    Mymultimap::generic_value gcval = *gcit;
    System::Console::Write("[{0} {1}] ", gcval->first, gcval->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]
[a 1]

multimap::generic_reverse_iterator

コンテナーのジェネリック インターフェイスで使用する反転反復子の型です。

構文

typedef Microsoft::VisualC::StlClr::Generic::
    ReverseRandomAccessIterator<generic_value>
    generic_reverse_iterator;

解説

この型は、このテンプレート コンテナー クラスのジェネリック インターフェイスで使用できるジェネリック反転反復子を表します。

// cliext_multimap_generic_reverse_iterator.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct a generic container
    Mymultimap::generic_container^ gc1 = %c1;
    for each (Mymultimap::value_type elem in gc1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // get an element and display it
    Mymultimap::generic_reverse_iterator gcit = gc1->rbegin();
    Mymultimap::generic_value gcval = *gcit;
    System::Console::WriteLine("[{0} {1}] ", gcval->first, gcval->second);
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]
[c 3]

multimap::generic_value

コンテナーのジェネリック インターフェイスで使用する要素の型です。

構文

typedef GValue generic_value;

解説

この型は、このテンプレート コンテナー クラスのジェネリック インターフェイスで使用する、格納されている要素の値を記述する GValue 型のオブジェクトを表します。

// cliext_multimap_generic_value.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct a generic container
    Mymultimap::generic_container^ gc1 = %c1;
    for each (Mymultimap::value_type elem in gc1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // get an element and display it
    Mymultimap::generic_iterator gcit = gc1->begin();
    Mymultimap::generic_value gcval = *gcit;
    System::Console::WriteLine("[{0} {1}] ", gcval->first, gcval->second);
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]
[a 1]

multimap::insert

要素を追加します。

構文

iterator insert(value_type val);
iterator insert(iterator where, value_type val);
template<typename InIter>
    void insert(InIter first, InIter last);
void insert(System::Collections::Generic::IEnumerable<value_type>^ right);

パラメーター

first
挿入する範囲の先頭。

last
挿入する範囲の末尾。

right
挿入する列挙型。

val
挿入するキー値。

where
コンテナー内の挿入位置 (ヒントのみ)。

解説

各メンバー関数は、残りのオペランドによって指定されたシーケンスを挿入します。

最初のメンバー関数は、値 valを持つ要素を挿入し、新しく挿入された要素を指定する反復子を返します。 1 つの要素を挿入する場合に、これを使用します。

2 番目のメンバー関数は、(パフォーマンスを向上させるために) ヒントとして使用して、値 valを持 where つ要素を挿入し、新しく挿入された要素を指定する反復子を返します。 これを使用して、知っている要素の横にある可能性のある 1 つの要素を挿入します。

3 つ目のメンバー関数は、シーケンス [first, last) を挿入します。 別のシーケンスからコピーした 0 個以上の要素を挿入する場合に、これを使用します。

4 番目のメンバー関数は、によって指定されたシーケンスを挿入します。right 列挙子によって記述されたシーケンスを挿入する場合に、これを使用します。

各要素の挿入には、被制御シーケンス内の要素数の対数に比例した時間が必要です。 ただし、挿入ポイントの横にある要素を指定するヒントを指定すると、挿入は償却定数時間で発生する可能性があります。

// cliext_multimap_insert.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // insert a single value, unique and duplicate
    Mymultimap::iterator it =
        c1.insert(Mymultimap::make_value(L'x', 24));
    System::Console::WriteLine("insert([L'x' 24]) = [{0} {1}]",
        it->first, it->second);

    it = c1.insert(Mymultimap::make_value(L'b', 2));
    System::Console::WriteLine("insert([L'b' 2]) = [{0} {1}]",
        it->first, it->second);

    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // insert a single value with hint
    it = c1.insert(c1.begin(), Mymultimap::make_value(L'y', 25));
    System::Console::WriteLine("insert(begin(), [L'y' 25]) = [{0} {1}]",
        it->first, it->second);
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // insert an iterator range
    Mymultimap c2;
    it = c1.end();
    c2.insert(c1.begin(), --it);
    for each (Mymultimap::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // insert an enumeration
    Mymultimap c3;
    c3.insert(   // NOTE: cast is not needed
        (System::Collections::Generic::
            IEnumerable<Mymultimap::value_type>^)%c1);
    for each (Mymultimap::value_type elem in c3)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
insert([L'x' 24]) = [x 24]
insert([L'b' 2]) = [b 2]
[a 1] [b 2] [b 2] [c 3] [x 24]
insert(begin(), [L'y' 25]) = [y 25]
[a 1] [b 2] [b 2] [c 3] [x 24] [y 25]
[a 1] [b 2] [b 2] [c 3] [x 24]
[a 1] [b 2] [b 2] [c 3] [x 24] [y 25]

multimap::iterator

被制御シーケンスの反復子の型です。

構文

typedef T1 iterator;

解説

この型は、被制御シーケンスの双方向反復子として使用できる未指定の T1 型のオブジェクトを表します。

// cliext_multimap_iterator.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    Mymultimap::iterator it = c1.begin();
    for (; it != c1.end(); ++it)
        System::Console::Write("[{0} {1}] ", it->first, it->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]

multimap::key_comp

2 つのキーの順序付けデリゲートをコピーします。

構文

key_compare^key_comp();

解説

このメンバー関数は、被制御シーケンスの順序付けに使用される順序付けデリゲートを返します。 これを使用して、2 つのキーを比較します。

// cliext_multimap_key_comp.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    Mymultimap::key_compare^ kcomp = c1.key_comp();

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        kcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        kcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        kcomp(L'b', L'a'));
    System::Console::WriteLine();

    // test a different ordering rule
    Mymultimap c2 = cliext::greater<wchar_t>();
    kcomp = c2.key_comp();

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        kcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        kcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        kcomp(L'b', L'a'));
    return (0);
    }
compare(L'a', L'a') = False
compare(L'a', L'b') = True
compare(L'b', L'a') = False

compare(L'a', L'a') = False
compare(L'a', L'b') = False
compare(L'b', L'a') = True

multimap::key_compare

2 つのキーの順序付けデリゲートです。

構文

Microsoft::VisualC::StlClr::BinaryDelegate<GKey, GKey, bool>
    key_compare;

解説

この型は、キー引数の順序付けを決定するデリゲートのシノニムです。

// cliext_multimap_key_compare.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    Mymultimap::key_compare^ kcomp = c1.key_comp();

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        kcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        kcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        kcomp(L'b', L'a'));
    System::Console::WriteLine();

    // test a different ordering rule
    Mymultimap c2 = cliext::greater<wchar_t>();
    kcomp = c2.key_comp();

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        kcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        kcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        kcomp(L'b', L'a'));
    return (0);
    }
compare(L'a', L'a') = False
compare(L'a', L'b') = True
compare(L'b', L'a') = False

compare(L'a', L'a') = False
compare(L'a', L'b') = False
compare(L'b', L'a') = True

multimap::key_type

順序付けキーの型です。

構文

typedef Key key_type;

解説

この型は、テンプレート パラメーター Keyのシノニムです。

// cliext_multimap_key_type.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]" using key_type
    for (Mymultimap::iterator it = c1.begin(); it != c1.end(); ++it)
        {   // store element in key_type object
        Mymultimap::key_type val = it->first;

        System::Console::Write("{0} ", val);
        }
    System::Console::WriteLine();
    return (0);
    }
a b c

multimap::lower_bound

指定したキーに一致する範囲の先頭を検索します。

構文

iterator lower_bound(key_type key);

パラメーター

key
検索対象のキー値。

解説

このメンバー関数は、同等の順序付けを持つ、制御シーケンス内の最初の要素 X を決定します key。 そのような要素が存在しない場合は返 end()されます。それ以外の場合は、指定する反復子を返します X。 指定したキーに一致する、被制御シーケンス内の現在の要素のシーケンスの先頭を検索する場合に使います。

// cliext_multimap_lower_bound.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("lower_bound(L'x')==end() = {0}",
        c1.lower_bound(L'x') == c1.end());

    Mymultimap::iterator it = c1.lower_bound(L'a');
    System::Console::WriteLine("*lower_bound(L'a') = [{0} {1}]",
        it->first, it->second);
    it = c1.lower_bound(L'b');
    System::Console::WriteLine("*lower_bound(L'b') = [{0} {1}]",
        it->first, it->second);
    return (0);
    }
[a 1] [b 2] [c 3]
lower_bound(L'x')==end() = True
*lower_bound(L'a') = [a 1]
*lower_bound(L'b') = [b 2]

multimap::make_value

値オブジェクトを構築します。

構文

static value_type make_value(key_type key, mapped_type mapped);

パラメーター

key
使用するキー値。

mapped
検索するマップされた値。

解説

このメンバー関数は、キーが value_type /& で key 、マップされた値 mappedが . 他のいくつかのメンバー関数での使用に適したオブジェクトを作成する場合に使います。

// cliext_multimap_make_value.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]

multimap::mapped_type

各キーに関連付けられた、マップされた値の型です。

構文

typedef Mapped mapped_type;

解説

この型は、テンプレート パラメーター Mappedのシノニムです。

// cliext_multimap_mapped_type.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]" using mapped_type
    for (Mymultimap::iterator it = c1.begin(); it != c1.end(); ++it)
        {   // store element in mapped_type object
        Mymultimap::mapped_type val = it->second;

        System::Console::Write("{0} ", val);
        }
    System::Console::WriteLine();
    return (0);
    }
1 2 3

multimap::multimap

コンテナー オブジェクトを構築します。

構文

multimap();
explicit multimap(key_compare^ pred);
multimap(multimap<Key, Mapped>% right);
multimap(multimap<Key, Mapped>^ right);
template<typename InIter>
    multimapmultimap(InIter first, InIter last);
template<typename InIter>
    multimap(InIter first, InIter last,
        key_compare^ pred);
multimap(System::Collections::Generic::IEnumerable<GValue>^ right);
multimap(System::Collections::Generic::IEnumerable<GValue>^ right,
    key_compare^ pred);

パラメーター

first
挿入する範囲の先頭。

last
挿入する範囲の末尾。

pred
被制御シーケンスの順序付けの述語。

right
挿入するオブジェクトまたは範囲。

解説

コンストラクター:

multimap();

既定の順序付けの述語 key_compare() を使って、要素のない被制御シーケンスを初期化します。 既定の順序付けの述語を使って、空の初期被制御シーケンスを指定する場合に使います。

コンストラクター:

explicit multimap(key_compare^ pred);

は、順序付け述語 predを使用して、要素なしで制御シーケンスを初期化します。 それを使って、指定した順序付けの述語で、空の初期被制御シーケンスを指定します。

コンストラクター:

multimap(multimap<Key, Mapped>% right);

既定の順序付けの述語を使用して、シーケンス [right.begin(), right.end()) で被制御シーケンスを初期化します。 これを使用して、既定の順序付け述語を使用して、オブジェクトrightによってmultimap制御されるシーケンスのコピーである初期被制御シーケンスを指定します。

コンストラクター:

multimap(multimap<Key, Mapped>^ right);

既定の順序付けの述語を使用して、シーケンス [right->begin(), right->end()) で被制御シーケンスを初期化します。 これを使用して、既定の順序付け述語を使用して、オブジェクトrightによってmultimap制御されるシーケンスのコピーである初期被制御シーケンスを指定します。

コンストラクター:

template<typename InIter> multimap(InIter first, InIter last);

既定の順序付けの述語を使用して、シーケンス [first, last) で被制御シーケンスを初期化します。 既定の順序付けの述語を使って、別のシーケンスのコピーを被制御シーケンスにする場合に使用します。

コンストラクター:

template<typename InIter> multimap(InIter first, InIter last, key_compare^ pred);

は、順序付け述語predを使用して、シーケンス [first, last) を使用して、制御シーケンスを初期化します。 指定した順序付けの述語を使って、別のシーケンスのコピーを被制御シーケンスにする場合に使用します。

コンストラクター:

multimap(System::Collections::Generic::IEnumerable<Key>^ right);

は、列挙子 rightによって指定されたシーケンスを使用して、既定の順序付け述語を使用して、制御シーケンスを初期化します。 既定の順序付けの述語を使って、列挙子によって記述された別のシーケンスのコピーを被制御シーケンスにする場合に使用します。

コンストラクター:

multimap(System::Collections::Generic::IEnumerable<Key>^ right, key_compare^ pred);

は、列挙子 rightによって指定されたシーケンスを使用して、順序付け述語を使用して、制御シーケンスを初期化します pred。 指定した順序付けの述語を使って、列挙子によって記述された別のシーケンスのコピーを被制御シーケンスにする場合に使用します。

// cliext_multimap_construct.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
// construct an empty container
    Mymultimap c1;
    System::Console::WriteLine("size() = {0}", c1.size());

    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct with an ordering rule
    Mymultimap c2 = cliext::greater_equal<wchar_t>();
    System::Console::WriteLine("size() = {0}", c2.size());

    c2.insert(c1.begin(), c1.end());
    for each (Mymultimap::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct with an iterator range
    Mymultimap c3(c1.begin(), c1.end());
    for each (Mymultimap::value_type elem in c3)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct with an iterator range and an ordering rule
    Mymultimap c4(c1.begin(), c1.end(),
        cliext::greater_equal<wchar_t>());
    for each (Mymultimap::value_type elem in c4)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct with an enumeration
    Mymultimap c5(   // NOTE: cast is not needed
        (System::Collections::Generic::IEnumerable<
            Mymultimap::value_type>^)%c3);
    for each (Mymultimap::value_type elem in c5)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct with an enumeration and an ordering rule
    Mymultimap c6(   // NOTE: cast is not needed
        (System::Collections::Generic::IEnumerable<
            Mymultimap::value_type>^)%c3,
                cliext::greater_equal<wchar_t>());
    for each (Mymultimap::value_type elem in c6)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct by copying another container
    Mymultimap c7(c4);
    for each (Mymultimap::value_type elem in c7)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct by copying a container handle
    Mymultimap c8(%c3);
    for each (Mymultimap::value_type elem in c8)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
size() = 0
[a 1] [b 2] [c 3]
size() = 0
[c 3] [b 2] [a 1]
[a 1] [b 2] [c 3]
[c 3] [b 2] [a 1]
[a 1] [b 2] [c 3]
[c 3] [b 2] [a 1]
[c 3] [b 2] [a 1]
[a 1] [b 2] [c 3]

multimap::operator=

被制御シーケンスを置き換えます。

構文

multimap<Key, Mapped>% operator=(multimap<Key, Mapped>% right);

パラメーター

right
コピーするコンテナー。

解説

メンバー演算子は、オブジェクトにコピー right し、次に返します *this。 これを使用して、被制御シーケンスを right の被制御シーケンスのコピーと置き換えます。

// cliext_multimap_operator_as.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // assign to a new container
    Mymultimap c2;
    c2 = c1;
// display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [c 3]

multimap::rbegin

反転被制御シーケンスの先頭を指定します。

構文

reverse_iterator rbegin();

解説

このメンバー関数は、被制御シーケンスの最後の要素 (または空のシーケンスの先頭の次の位置) を指定する反転反復子を返します。 したがって、逆シーケンスを beginning 指定します。 これを使用して、被制御シーケンスの先頭を current 逆の順序で指定する反復子を取得しますが、被制御シーケンスの長さが変わると状態が変わる可能性があります。

// cliext_multimap_rbegin.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect first two items in reversed sequence
    Mymultimap::reverse_iterator rit = c1.rbegin();
    System::Console::WriteLine("*rbegin() = [{0} {1}]",
        rit->first, rit->second);
    ++rit;
    System::Console::WriteLine("*++rbegin() = [{0} {1}]",
        rit->first, rit->second);
    return (0);
    }
[a 1] [b 2] [c 3]
*rbegin() = [c 3]
*++rbegin() = [b 2]

multimap::reference

要素への参照の型です。

構文

typedef value_type% reference;

解説

この型は、要素への参照を表します。

// cliext_multimap_reference.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    Mymultimap::iterator it = c1.begin();
    for (; it != c1.end(); ++it)
        {   // get a reference to an element
        Mymultimap::reference ref = *it;
        System::Console::Write("[{0} {1}] ", ref->first, ref->second);
        }
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]

multimap::rend

反転被制御シーケンスの末尾を指定します。

構文

reverse_iterator rend();

解説

このメンバー関数は、被制御シーケンスの先頭を超えた位置を示す反転反復子を返します。 したがって、逆シーケンスを end 指定します。 これを使用して、被制御シーケンスの末尾を逆の順序で指定 current する反復子を取得しますが、被制御シーケンスの長さが変わると状態が変わる可能性があります。

// cliext_multimap_rend.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // inspect first two items in reversed sequence
    Mymultimap::reverse_iterator rit = c1.rend();
    --rit;
    --rit;
    System::Console::WriteLine("*-- --rend() = [{0} {1}]",
        rit->first, rit->second);
    ++rit;
    System::Console::WriteLine("*--rend() = [{0} {1}]",
        rit->first, rit->second);
    return (0);
    }
[a 1] [b 2] [c 3]
*-- --rend() = [b 2]
*--rend() = [a 1]

multimap::reverse_iterator

被制御シーケンスの反転反復子の型です。

構文

typedef T3 reverse_iterator;

解説

この型は、被制御シーケンスの反転反復子として使用できる未指定の T3 型のオブジェクトを表します。

// cliext_multimap_reverse_iterator.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]" reversed
    Mymultimap::reverse_iterator rit = c1.rbegin();
    for (; rit != c1.rend(); ++rit)
        System::Console::Write("[{0} {1}] ", rit->first, rit->second);
    System::Console::WriteLine();
    return (0);
    }
[c 3] [b 2] [a 1]

multimap::size

要素の数をカウントします。

構文

size_type size();

解説

このメンバー関数は、被制御シーケンスの長さを返します。 被制御シーケンス内の現在の要素の数を特定する場合に使います。 シーケンスに 0 以外のサイズがあるかどうかを考慮する必要がある場合は、次を参照してください empty()

// cliext_multimap_size.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // clear the container and reinspect
    c1.clear();
    System::Console::WriteLine("size() = {0} after clearing", c1.size());

    // add elements and clear again
    c1.insert(Mymultimap::make_value(L'd', 4));
    c1.insert(Mymultimap::make_value(L'e', 5));
    System::Console::WriteLine("size() = {0} after adding 2", c1.size());
    return (0);
    }
[a 1] [b 2] [c 3]
size() = 0 after clearing
size() = 2 after adding 2

multimap::size_type

2 つの要素間の距離を表す、符号付きの型です。

構文

typedef int size_type;

解説

この型は、負でない要素数を表します。

// cliext_multimap_size_type.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // compute positive difference
    Mymultimap::size_type diff = 0;
    for (Mymultimap::iterator it = c1.begin(); it != c1.end(); ++it)
        ++diff;
    System::Console::WriteLine("end()-begin() = {0}", diff);
    return (0);
    }
[a 1] [b 2] [c 3]
end()-begin() = 3

multimap::swap

2 つのコンテナーのコンテンツを交換します。

構文

void swap(multimap<Key, Mapped>% right);

パラメーター

right
コンテンツを交換するコンテナー。

解説

このメンバー関数は、thisright の間で被制御シーケンスを交換します。 一定時間に実行し、例外をスローしません。 2 つのコンテナーのコンテンツを簡単に交換する方法として、これを使用します。

// cliext_multimap_swap.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // construct another container with repetition of values
    Mymultimap c2;
    c2.insert(Mymultimap::make_value(L'd', 4));
    c2.insert(Mymultimap::make_value(L'e', 5));
    c2.insert(Mymultimap::make_value(L'f', 6));
    for each (Mymultimap::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // swap and redisplay
    c1.swap(c2);
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    for each (Mymultimap::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]
[d 4] [e 5] [f 6]
[d 4] [e 5] [f 6]
[a 1] [b 2] [c 3]

multimap::to_array

被制御シーケンスを新しい配列にコピーします。

構文

cli::array<value_type>^ to_array();

解説

このメンバー関数は、被制御シーケンスを含む配列を返します。 配列形式の被制御シーケンスのコピーを取得する場合に、これを使用します。

// cliext_multimap_to_array.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // copy the container and modify it
    cli::array<Mymultimap::value_type>^ a1 = c1.to_array();

    c1.insert(Mymultimap::make_value(L'd', 4));
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // display the earlier array copy
    for each (Mymultimap::value_type elem in a1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3] [d 4]
[a 1] [b 2] [c 3]

multimap::upper_bound

指定したキーに一致する範囲の末尾を検索します。

構文

iterator upper_bound(key_type key);

パラメーター

key
検索対象のキー値。

解説

このメンバー関数は、同等の順序を持つ、制御シーケンス内の最後の要素 X を決定します key。 このような要素が存在しない場合、または被制御シーケンスの最後の要素である場合 X は返されます。それ以外の場合は、 end()最初の要素を指定 Xする反復子を返します。 指定したキーに一致する、被制御シーケンス内の現在の要素のシーケンスの末尾を検索する場合に使います。

// cliext_multimap_upper_bound.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("upper_bound(L'x')==end() = {0}",
        c1.upper_bound(L'x') == c1.end());

    Mymultimap::iterator it = c1.upper_bound(L'a');
    System::Console::WriteLine("*upper_bound(L'a') = [{0} {1}]",
        it->first, it->second);
    it = c1.upper_bound(L'b');
    System::Console::WriteLine("*upper_bound(L'b') = [{0} {1}]",
        it->first, it->second);
    return (0);
    }
[a 1] [b 2] [c 3]
upper_bound(L'x')==end() = True
*upper_bound(L'a') = [b 2]
*upper_bound(L'b') = [c 3]

multimap::value_comp

2 つの要素値の順序付けデリゲートをコピーします。

構文

value_compare^ value_comp();

解説

このメンバー関数は、被制御シーケンスの順序付けに使用される順序付けデリゲートを返します。 2 つの要素値を比較する場合に、これを使用します。

// cliext_multimap_value_comp.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::map<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    Mymultimap::value_compare^ kcomp = c1.value_comp();

    System::Console::WriteLine("compare([L'a', 1], [L'a', 1]) = {0}",
        kcomp(Mymultimap::make_value(L'a', 1),
            Mymultimap::make_value(L'a', 1)));
    System::Console::WriteLine("compare([L'a', 1], [L'b', 2]) = {0}",
        kcomp(Mymultimap::make_value(L'a', 1),
            Mymultimap::make_value(L'b', 2)));
    System::Console::WriteLine("compare([L'b', 2], [L'a', 1]) = {0}",
        kcomp(Mymultimap::make_value(L'b', 2),
            Mymultimap::make_value(L'a', 1)));
    System::Console::WriteLine();
    return (0);
    }
compare([L'a', 1], [L'a', 1]) = False
compare([L'a', 1], [L'b', 2]) = True
compare([L'b', 2], [L'a', 1]) = False

multimap::value_compare

2 つの要素値の順序付けデリゲートです。

構文

Microsoft::VisualC::StlClr::BinaryDelegate<generic_value, generic_value, bool>
    value_compare;

解説

この型は、値の引数の順序付けを決定するデリゲートのシノニムです。

// cliext_multimap_value_compare.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::map<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    Mymultimap::value_compare^ kcomp = c1.value_comp();

    System::Console::WriteLine("compare([L'a', 1], [L'a', 1]) = {0}",
        kcomp(Mymultimap::make_value(L'a', 1),
            Mymultimap::make_value(L'a', 1)));
    System::Console::WriteLine("compare([L'a', 1], [L'b', 2]) = {0}",
        kcomp(Mymultimap::make_value(L'a', 1),
            Mymultimap::make_value(L'b', 2)));
    System::Console::WriteLine("compare([L'b', 2], [L'a', 1]) = {0}",
        kcomp(Mymultimap::make_value(L'b', 2),
            Mymultimap::make_value(L'a', 1)));
    System::Console::WriteLine();
    return (0);
    }
compare([L'a', 1], [L'a', 1]) = False
compare([L'a', 1], [L'b', 2]) = True
compare([L'b', 2], [L'a', 1]) = False

multimap::value_type

要素の型。

構文

typedef generic_value value_type;

解説

型は、generic_value の同意語。

// cliext_multimap_value_type.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]" using value_type
    for (Mymultimap::iterator it = c1.begin(); it != c1.end(); ++it)
        {   // store element in value_type object
        Mymultimap::value_type val = *it;
        System::Console::Write("[{0} {1}] ", val->first, val->second);
        }
    System::Console::WriteLine();
    return (0);
    }
[a 1] [b 2] [c 3]

operator!= (multimap)

リストが等しくないかどうかの比較です。

構文

template<typename Key,
    typename Mapped>
    bool operator!=(multimap<Key, Mapped>% left,
        multimap<Key, Mapped>% right);

パラメーター

left
比較する左のコンテナー。

right
比較する右のコンテナー。

解説

この演算子関数は、!(left == right) を返します。 これを使用して、2 つのマルチマップが要素ごとに比較される場合とright同じ順序になっていないかどうかをleftテストします。

// cliext_multimap_operator_ne.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // assign to a new container
    Mymultimap c2;
    c2.insert(Mymultimap::make_value(L'a', 1));
    c2.insert(Mymultimap::make_value(L'b', 2));
    c2.insert(Mymultimap::make_value(L'd', 4));

    // display contents " [a 1] [b 2] [d 4]"
    for each (Mymultimap::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("[a b c] != [a b c] is {0}",
        c1 != c1);
    System::Console::WriteLine("[a b c] != [a b d] is {0}",
        c1 != c2);
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [d 4]
[a b c] != [a b c] is False
[a b c] != [a b d] is True

operator< (multimap)

リストがより小さいかどうかの比較です。

構文

template<typename Key,
    typename Mapped>
    bool operator<(multimap<Key, Mapped>% left,
        multimap<Key, Mapped>% right);

パラメーター

left
比較する左のコンテナー。

right
比較する右のコンテナー。

解説

演算子関数は true を返します場合は、最も低い位置i!(right[i] < left[i])の場合は true を返しますleft[i] < right[i]。 それ以外の場合は left->size() < right->size()を返します。 これを使用して、2 つのマルチマップが要素ごとに比較される前rightに順序付けされているかどうかをleftテストします。

// cliext_multimap_operator_lt.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // assign to a new container
    Mymultimap c2;
    c2.insert(Mymultimap::make_value(L'a', 1));
    c2.insert(Mymultimap::make_value(L'b', 2));
    c2.insert(Mymultimap::make_value(L'd', 4));

    // display contents " [a 1] [b 2] [d 4]"
    for each (Mymultimap::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("[a b c] < [a b c] is {0}",
        c1 < c1);
    System::Console::WriteLine("[a b c] < [a b d] is {0}",
        c1 < c2);
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [d 4]
[a b c] < [a b c] is False
[a b c] < [a b d] is True

operator<= (multimap)

リストが以下であるかどうかの比較です。

構文

template<typename Key,
    typename Mapped>
    bool operator<=(multimap<Key, Mapped>% left,
        multimap<Key, Mapped>% right);

パラメーター

left
比較する左のコンテナー。

right
比較する右のコンテナー。

解説

この演算子関数は、!(right < left) を返します。 これを使用して、2 つのマルチマップが要素ごとに比較される場合に、その後rightに並べ替えられていないかどうかをleftテストします。

// cliext_multimap_operator_le.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // assign to a new container
    Mymultimap c2;
    c2.insert(Mymultimap::make_value(L'a', 1));
    c2.insert(Mymultimap::make_value(L'b', 2));
    c2.insert(Mymultimap::make_value(L'd', 4));

    // display contents " [a 1] [b 2] [d 4]"
    for each (Mymultimap::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("[a b c] <= [a b c] is {0}",
        c1 <= c1);
    System::Console::WriteLine("[a b d] <= [a b c] is {0}",
        c2 <= c1);
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [d 4]
[a b c] <= [a b c] is True
[a b d] <= [a b c] is False

operator== (multimap)

リストが等しいかどうかの比較です。

構文

template<typename Key,
    typename Mapped>
    bool operator==(multimap<Key, Mapped>% left,
        multimap<Key, Mapped>% right);

パラメーター

left
比較する左のコンテナー。

right
比較する右のコンテナー。

解説

演算子関数は、制御されるシーケンスの長さが同じで、各位置ileft[i] == right[i]に対してleftright同じ場合にのみ true を返します。 これを使用して、2 つのマルチマップが要素ごとに比較される場合とright同じ順序になっているかどうかをleftテストします。

// cliext_multimap_operator_eq.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // assign to a new container
    Mymultimap c2;
    c2.insert(Mymultimap::make_value(L'a', 1));
    c2.insert(Mymultimap::make_value(L'b', 2));
    c2.insert(Mymultimap::make_value(L'd', 4));

    // display contents " [a 1] [b 2] [d 4]"
    for each (Mymultimap::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("[a b c] == [a b c] is {0}",
        c1 == c1);
    System::Console::WriteLine("[a b c] == [a b d] is {0}",
        c1 == c2);
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [d 4]
[a b c] == [a b c] is True
[a b c] == [a b d] is False

operator> (multimap)

リストがより大きいかどうかの比較です。

構文

template<typename Key,
    typename Mapped>
    bool operator>(multimap<Key, Mapped>% left,
        multimap<Key, Mapped>% right);

パラメーター

left
比較する左のコンテナー。

right
比較する右のコンテナー。

解説

この演算子関数は、right < left を返します。 これを使用して、2 つのマルチマップが要素ごとに比較された後rightに並べ替えられるかどうかをleftテストします。

// cliext_multimap_operator_gt.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // assign to a new container
    Mymultimap c2;
    c2.insert(Mymultimap::make_value(L'a', 1));
    c2.insert(Mymultimap::make_value(L'b', 2));
    c2.insert(Mymultimap::make_value(L'd', 4));

    // display contents " [a 1] [b 2] [d 4]"
    for each (Mymultimap::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("[a b c] > [a b c] is {0}",
        c1 > c1);
    System::Console::WriteLine("[a b d] > [a b c] is {0}",
        c2 > c1);
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [d 4]
[a b c] > [a b c] is False
[a b d] > [a b c] is True

operator>= (multimap)

リストが以上であるかどうかの比較です。

構文

template<typename Key,
    typename Mapped>
    bool operator>=(multimap<Key, Mapped>% left,
        multimap<Key, Mapped>% right);

パラメーター

left
比較する左のコンテナー。

right
比較する右のコンテナー。

解説

この演算子関数は、!(left < right) を返します。 これを使用して、2 つのマルチマップが要素ごとに比較される前にright順序付けされていないかどうかをleftテストします。

// cliext_multimap_operator_ge.cpp
// compile with: /clr
#include <cliext/map>

typedef cliext::multimap<wchar_t, int> Mymultimap;
int main()
    {
    Mymultimap c1;
    c1.insert(Mymultimap::make_value(L'a', 1));
    c1.insert(Mymultimap::make_value(L'b', 2));
    c1.insert(Mymultimap::make_value(L'c', 3));

    // display contents " [a 1] [b 2] [c 3]"
    for each (Mymultimap::value_type elem in c1)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    // assign to a new container
    Mymultimap c2;
    c2.insert(Mymultimap::make_value(L'a', 1));
    c2.insert(Mymultimap::make_value(L'b', 2));
    c2.insert(Mymultimap::make_value(L'd', 4));

    // display contents " [a 1] [b 2] [d 4]"
    for each (Mymultimap::value_type elem in c2)
        System::Console::Write("[{0} {1}] ", elem->first, elem->second);
    System::Console::WriteLine();

    System::Console::WriteLine("[a b c] >= [a b c] is {0}",
        c1 >= c1);
    System::Console::WriteLine("[a b c] >= [a b d] is {0}",
        c1 >= c2);
    return (0);
    }
[a 1] [b 2] [c 3]
[a 1] [b 2] [d 4]
[a b c] >= [a b c] is True
[a b c] >= [a b d] is False