Share via


multiset (STL/CLR)

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

以下の説明では、と同じですが、GValue後者が ref 型でない限り同じですKey。その場合は Key^.GKey

構文

template<typename Key>
    ref class multiset
        :   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
制御シーケンス内の要素のキー コンポーネントの型。

必要条件

ヘッダー:<cliext/set>

名前空間cliext:

宣言

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

インターフェイス

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

解説

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

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

このようなデリゲート オブジェクトは、型 multiset::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) とは異なり、テンプレート クラス multiset のオブジェクトでは、すべての要素のキーが一意である必要はありません。 (2 つ以上のキーの順序付けを等しくすることができます)。

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

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

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

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

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

メンバー

multiset::begin

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

構文

iterator begin();

解説

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

// cliext_multiset_begin.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // inspect first two items
    Mymultiset::iterator it = c1.begin();
    System::Console::WriteLine("*begin() = {0}", *it);
    System::Console::WriteLine("*++begin() = {0}", *++it);
    return (0);
    }
a b c
*begin() = a
*++begin() = b

multiset::clear

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

構文

void clear();

解説

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

// cliext_multiset_clear.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

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

    // add elements and clear again
    c1.insert(L'a');
    c1.insert(L'b');

    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    c1.clear();
    System::Console::WriteLine("size() = {0}", c1.size());
    return (0);
    }
a b c
size() = 0
a b
size() = 0

multiset::const_iterator

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

構文

typedef T2 const_iterator;

解説

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

// cliext_multiset_const_iterator.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c"
    Mymultiset::const_iterator cit = c1.begin();
    for (; cit != c1.end(); ++cit)
        System::Console::Write("{0} ", *cit);
    System::Console::WriteLine();
    return (0);
    }
a b c

multiset::const_reference

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

構文

typedef value_type% const_reference;

解説

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

// cliext_multiset_const_reference.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    Mymultiset::const_iterator cit = c1.begin();
    for (; cit != c1.end(); ++cit)
        {   // get a const reference to an element
        Mymultiset::const_reference cref = *cit;
        System::Console::Write("{0} ", cref);
        }
    System::Console::WriteLine();
    return (0);
    }
a b c

multiset::const_reverse_iterator

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

構文

typedef T4 const_reverse_iterator;

解説

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

// cliext_multiset_const_reverse_iterator.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c" reversed
    Mymultiset::const_reverse_iterator crit = c1.rbegin();
    for (; crit != c1.rend(); ++crit)
        System::Console::Write("{0} ", *crit);
    System::Console::WriteLine();
    return (0);
    }
c b a

multiset::count

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

構文

size_type count(key_type key);

パラメーター

key
検索対象のキー値。

解説

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

// cliext_multiset_count.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    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 b c
count(L'A') = 0
count(L'b') = 1
count(L'C') = 0

multiset::difference_type

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

構文

typedef int difference_type;

解説

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

// cliext_multiset_difference_type.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

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

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

multiset::empty

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

構文

bool empty();

解説

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

// cliext_multiset_empty.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    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 b c
size() = 3
empty() = False
size() = 0
empty() = True

multiset::end

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

構文

iterator end();

解説

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

// cliext_multiset_end.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // inspect last two items
    Mymultiset::iterator it = c1.end();
    --it;
    System::Console::WriteLine("*-- --end() = {0}", *--it);
    System::Console::WriteLine("*--end() = {0}", *++it);
    return (0);
    }
a b c
*-- --end() = b
*--end() = c

multiset::equal_range

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

構文

cliext::pair<iterator, iterator> equal_range(key_type key);

パラメーター

key
検索対象のキー値。

解説

このメンバー関数は、反復子 cliext::pair<iterator, iterator>(lower_bound(key), upper_bound(key)) のペアを返します。 指定したキーに一致する、被制御シーケンス内の現在の要素の範囲を特定するために使います。

// cliext_multiset_equal_range.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
typedef Mymultiset::pair_iter_iter Pairii;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    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} ", *pair1.first);
    System::Console::WriteLine();
    return (0);
    }
a b c
equal_range(L'x') empty = True
b

multiset::erase

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

構文

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

パラメーター

first
消去する範囲の先頭。

key
消去するキー値。

last
消去する範囲の末尾。

where
消去する要素。

解説

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

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

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

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

// cliext_multiset_erase.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // erase an element and reinspect
    System::Console::WriteLine("erase(begin()) = {0}",
        *c1.erase(c1.begin()));

    // add elements and display " b c d e"
    c1.insert(L'd');
    c1.insert(L'e');
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // erase all but end
    Mymultiset::iterator it = c1.end();
    System::Console::WriteLine("erase(begin(), end()-1) = {0}",
        *c1.erase(c1.begin(), --it));
    System::Console::WriteLine("size() = {0}", c1.size());
    return (0);
    }
a b c
erase(begin()) = b
b c d e
erase(begin(), end()-1) = e
size() = 1

multiset::find

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

構文

iterator find(key_type key);

パラメーター

key
検索対象のキー値。

解説

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

// cliext_multiset_find.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

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

multiset::generic_container

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

構文

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

解説

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

// cliext_multiset_generic_container.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // construct a generic container
    Mymultiset::generic_container^ gc1 = %c1;
    for each (wchar_t elem in gc1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // modify generic and display original
    gc1->insert(L'd');
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // modify original and display generic
    c1.insert(L'e');
    for each (wchar_t elem in gc1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
a b c
a b c d
a b c d e

multiset::generic_iterator

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

構文

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

解説

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

// cliext_multiset_generic_iterator.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // construct a generic container
    Mymultiset::generic_container^ gc1 = %c1;
    for each (wchar_t elem in gc1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // get an element and display it
    Mymultiset::generic_iterator gcit = gc1->begin();
    Mymultiset::generic_value gcval = *gcit;
    System::Console::WriteLine("{0} ", gcval);
    return (0);
    }
a b c
a b c
a

multiset::generic_reverse_iterator

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

構文

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

解説

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

// cliext_multiset_generic_reverse_iterator.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // construct a generic container
    Mymultiset::generic_container^ gc1 = %c1;
    for each (wchar_t elem in gc1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // get an element and display it
    Mymultiset::generic_reverse_iterator gcit = gc1->rbegin();
    Mymultiset::generic_value gcval = *gcit;
    System::Console::WriteLine("{0} ", gcval);
    return (0);
    }
a b c
a b c
c

multiset::generic_value

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

構文

typedef GValue generic_value;

解説

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

// cliext_multiset_generic_value.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // construct a generic container
    Mymultiset::generic_container^ gc1 = %c1;
    for each (wchar_t elem in gc1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // get an element and display it
    Mymultiset::generic_iterator gcit = gc1->begin();
    Mymultiset::generic_value gcval = *gcit;
    System::Console::WriteLine("{0} ", gcval);
    return (0);
    }
a b c
a b c
a

multiset::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_multiset_insert.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // insert a single value, unique and duplicate
    System::Console::WriteLine("insert(L'x') = {0}",
        *c1.insert(L'x'));

    System::Console::WriteLine("insert(L'b') = {0}",
        *c1.insert(L'b'));

    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // insert a single value with hint
    System::Console::WriteLine("insert(begin(), L'y') = {0}",
        *c1.insert(c1.begin(), L'y'));
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // insert an iterator range
    Mymultiset c2;
    Mymultiset::iterator it = c1.end();
    c2.insert(c1.begin(), --it);
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // insert an enumeration
    Mymultiset c3;
    c3.insert(   // NOTE: cast is not needed
        (System::Collections::Generic::IEnumerable<wchar_t>^)%c1);
    for each (wchar_t elem in c3)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
insert(L'x') = x
insert(L'b') = b
a b b c x
insert(begin(), L'y') = y
a b b c x y
a b b c x
a b b c x y

multiset::iterator

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

構文

typedef T1 iterator;

解説

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

// cliext_multiset_iterator.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c"
    Mymultiset::iterator it = c1.begin();
    for (; it != c1.end(); ++it)
        System::Console::Write("{0} ", *it);
    System::Console::WriteLine();
    return (0);
    }
a b c

multiset::key_comp

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

構文

key_compare^key_comp();

解説

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

// cliext_multiset_key_comp.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    Mymultiset::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
    Mymultiset 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

multiset::key_compare

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

構文

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

解説

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

// cliext_multiset_key_compare.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    Mymultiset::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
    Mymultiset 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

multiset::key_type

順序付けキーの型です。

構文

typedef Key key_type;

解説

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

// cliext_multiset_key_type.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c" using key_type
    for (Mymultiset::iterator it = c1.begin(); it != c1.end(); ++it)
        {   // store element in key_type object
        Mymultiset::key_type val = *it;

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

multiset::lower_bound

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

構文

iterator lower_bound(key_type key);

パラメーター

key
検索対象のキー値。

解説

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

// cliext_multiset_lower_bound.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

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

    System::Console::WriteLine("*lower_bound(L'a') = {0}",
        *c1.lower_bound(L'a'));
    System::Console::WriteLine("*lower_bound(L'b') = {0}",
        *c1.lower_bound(L'b'));
    return (0);
    }
a b c
lower_bound(L'x')==end() = True
*lower_bound(L'a') = a
*lower_bound(L'b') = b

multiset::make_value

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

構文

static value_type make_value(key_type key);

パラメーター

key
使用するキー値。

解説

メンバー関数は、キーkeyvalue_type . 他のいくつかのメンバー関数での使用に適したオブジェクトを作成する場合に使います。

// cliext_multiset_make_value.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(Mymultiset::make_value(L'a'));
    c1.insert(Mymultiset::make_value(L'b'));
    c1.insert(Mymultiset::make_value(L'c'));

    // display contents " a b c"
    for each (Mymultiset::value_type elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c

multiset::multiset

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

構文

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

パラメーター

first
挿入する範囲の先頭。

last
挿入する範囲の末尾。

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

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

解説

コンストラクター:

multiset();

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

コンストラクター:

explicit multiset(key_compare^ pred);

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

コンストラクター:

multiset(multiset<Key>% right);

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

コンストラクター:

multiset(multiset<Key>^ right);

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

コンストラクター:

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

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

コンストラクター:

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

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

コンストラクター:

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

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

コンストラクター:

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

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

// cliext_multiset_construct.cpp
// compile with: /clr
#include <cliext/set>

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

    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

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

    c2.insert(c1.begin(), c1.end());
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // construct with an iterator range
    Mymultiset c3(c1.begin(), c1.end());
    for each (wchar_t elem in c3)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

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

    // construct with an enumeration
    Mymultiset c5(   // NOTE: cast is not needed
        (System::Collections::Generic::IEnumerable<wchar_t>^)%c3);
    for each (wchar_t elem in c5)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

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

    // construct from a generic container
    Mymultiset c7(c4);
    for each (wchar_t elem in c7)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // construct by copying another container
    Mymultiset c8(%c3);
    for each (wchar_t elem in c8)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
size() = 0
a b c
size() = 0
c b a
a b c
c b a
a b c
c b a
c b a
a b c

multiset::operator=

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

構文

multiset<Key>% operator=(multiset<Key>% right);

パラメーター

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

解説

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

// cliext_multiset_operator_as.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c"
    for each (Mymultiset::value_type elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // assign to a new container
    Mymultiset c2;
    c2 = c1;
// display contents " a b c"
    for each (Mymultiset::value_type elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
a b c

multiset::rbegin

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

構文

reverse_iterator rbegin();

解説

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

// cliext_multiset_rbegin.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // inspect first two items in reversed sequence
    Mymultiset::reverse_iterator rit = c1.rbegin();
    System::Console::WriteLine("*rbegin() = {0}", *rit);
    System::Console::WriteLine("*++rbegin() = {0}", *++rit);
    return (0);
    }
a b c
*rbegin() = c
*++rbegin() = b

multiset::reference

要素への参照の型です。

構文

typedef value_type% reference;

解説

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

// cliext_multiset_reference.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    Mymultiset::iterator it = c1.begin();
    for (; it != c1.end(); ++it)
        {   // get a reference to an element
        Mymultiset::reference ref = *it;
        System::Console::Write("{0} ", ref);
        }
    System::Console::WriteLine();
    return (0);
    }
a b c

multiset::rend

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

構文

reverse_iterator rend();

解説

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

// cliext_multiset_rend.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // inspect first two items
    Mymultiset::reverse_iterator rit = c1.rend();
    --rit;
    System::Console::WriteLine("*-- --rend() = {0}", *--rit);
    System::Console::WriteLine("*--rend() = {0}", *++rit);
    return (0);
    }
a b c
*-- --rend() = b
*--rend() = a

multiset::reverse_iterator

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

構文

typedef T3 reverse_iterator;

解説

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

// cliext_multiset_reverse_iterator.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c" reversed
    Mymultiset::reverse_iterator rit = c1.rbegin();
    for (; rit != c1.rend(); ++rit)
        System::Console::Write("{0} ", *rit);
    System::Console::WriteLine();
    return (0);
    }
c b a

multiset::size

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

構文

size_type size();

解説

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

// cliext_multiset_size.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    System::Console::WriteLine("size() = {0} starting with 3", c1.size());

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

    // add elements and clear again
    c1.insert(L'a');
    c1.insert(L'b');
    System::Console::WriteLine("size() = {0} after adding 2", c1.size());
    return (0);
    }
a b c
size() = 3 starting with 3
size() = 0 after clearing
size() = 2 after adding 2

multiset::size_type

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

構文

typedef int size_type;

解説

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

// cliext_multiset_size_type.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

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

multiset::swap

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

構文

void swap(multiset<Key>% right);

パラメーター

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

解説

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

// cliext_multiset_swap.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // construct another container with repetition of values
    Mymultiset c2;
    c2.insert(L'd');
    c2.insert(L'e');
    c2.insert(L'f');
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // swap and redisplay
    c1.swap(c2);
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
d e f
d e f
a b c

multiset::to_array

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

構文

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

解説

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

// cliext_multiset_to_array.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

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

    c1.insert(L'd');
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // display the earlier array copy
    for each (wchar_t elem in a1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c d
a b c

multiset::upper_bound

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

構文

iterator upper_bound(key_type key);

パラメーター

key
検索対象のキー値。

解説

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

// cliext_multiset_upper_bound.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

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

    System::Console::WriteLine("*upper_bound(L'a') = {0}",
        *c1.upper_bound(L'a'));
    System::Console::WriteLine("*upper_bound(L'b') = {0}",
        *c1.upper_bound(L'b'));
    return (0);
    }
a b c
upper_bound(L'x')==end() = True
*upper_bound(L'a') = b
*upper_bound(L'b') = c

multiset::value_comp

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

構文

value_compare^ value_comp();

解説

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

// cliext_multiset_value_comp.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    Mymultiset::value_compare^ kcomp = c1.value_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();
    return (0);
    }
compare(L'a', L'a') = False
compare(L'a', L'b') = True
compare(L'b', L'a') = False

multiset::value_compare

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

構文

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

解説

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

// cliext_multiset_value_compare.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    Mymultiset::value_compare^ kcomp = c1.value_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();
    return (0);
    }
compare(L'a', L'a') = False
compare(L'a', L'b') = True
compare(L'b', L'a') = False

multiset::value_type

要素の型。

構文

typedef generic_value value_type;

解説

型は、generic_value の同意語。

// cliext_multiset_value_type.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c" using value_type
    for (Mymultiset::iterator it = c1.begin(); it != c1.end(); ++it)
        {   // store element in value_type object
        Mymultiset::value_type val = *it;

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

operator!= (multiset)

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

構文

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

パラメーター

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

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

解説

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

// cliext_multiset_operator_ne.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // assign to a new container
    Mymultiset c2;
    c2.insert(L'a');
    c2.insert(L'b');
    c2.insert(L'd');

    // display contents " a b d"
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    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 b c
a b d
[a b c] != [a b c] is False
[a b c] != [a b d] is True

operator< (multiset) (STL/CLR)

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

構文

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

パラメーター

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

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

解説

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

// cliext_multiset_operator_lt.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // assign to a new container
    Mymultiset c2;
    c2.insert(L'a');
    c2.insert(L'b');
    c2.insert(L'd');

    // display contents " a b d"
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    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 b c
a b d
[a b c] < [a b c] is False
[a b c] < [a b d] is True

operator<= (multiset)

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

構文

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

パラメーター

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

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

解説

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

// cliext_multiset_operator_le.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // assign to a new container
    Mymultiset c2;
    c2.insert(L'a');
    c2.insert(L'b');
    c2.insert(L'd');

    // display contents " a b d"
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    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 b c
a b d
[a b c] <= [a b c] is True
[a b d] <= [a b c] is False

operator== (multiset)

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

構文

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

パラメーター

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

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

解説

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

// cliext_multiset_operator_eq.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // assign to a new container
    Mymultiset c2;
    c2.insert(L'a');
    c2.insert(L'b');
    c2.insert(L'd');

    // display contents " a b d"
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    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 b c
a b d
[a b c] == [a b c] is True
[a b c] == [a b d] is False

operator> (multiset)

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

構文

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

パラメーター

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

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

解説

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

// cliext_multiset_operator_gt.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // assign to a new container
    Mymultiset c2;
    c2.insert(L'a');
    c2.insert(L'b');
    c2.insert(L'd');

    // display contents " a b d"
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    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 b c
a b d
[a b c] > [a b c] is False
[a b d] > [a b c] is True

operator>= (multiset)

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

構文

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

パラメーター

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

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

解説

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

// cliext_multiset_operator_ge.cpp
// compile with: /clr
#include <cliext/set>

typedef cliext::multiset<wchar_t> Mymultiset;
int main()
    {
    Mymultiset c1;
    c1.insert(L'a');
    c1.insert(L'b');
    c1.insert(L'c');

    // display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // assign to a new container
    Mymultiset c2;
    c2.insert(L'a');
    c2.insert(L'b');
    c2.insert(L'd');

    // display contents " a b d"
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    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 b c
a b d
[a b c] >= [a b c] is True
[a b c] >= [a b d] is False