multiset::multiset
空か、他の複数のセットのすべてまたは一部のコピーに多重セットを構築します。
multiset( );
explicit multiset (
const Compare& _Comp
);
multiset (
const Compare& _Comp,
const Allocator& _Al
);
multiset(
const multiset& _Right
);
template<class InputIterator>
multiset (
InputIterator _First,
InputIterator _Last
);
template<class InputIterator>
multiset (
InputIterator _First,
InputIterator _Last,
const Compare& _Comp
);
template<class InputIterator>
multiset (
InputIterator _First,
InputIterator _Last,
const Compare& _Comp,
const Allocator& _Al
);
multiset(
multiset&& _Right
);
パラメーター
パラメーター |
説明 |
_Al |
Allocatorに既定では、このセットのオブジェクトに使用するストレージのアロケーター クラス。 |
_Comp |
Compareに既定では、多重セットの要素を並べ替えに使用される型 [const]Compare の比較関数。 |
_Right |
構築された複数のセットがコピーであることに多重セット。 |
_First |
コピーする要素範囲内の先頭の要素の位置。 |
_Last |
コピーする要素範囲を超える最初の要素の位置。 |
解説
すべてのコンストラクターは複数のセットのメモリの記憶域を管理する get_allocatorを呼び出して後で、アロケーター オブジェクトの種類を格納します。アロケーターのパラメーターは、代替アロケーターを置き換えるために使用されるクラスの宣言とプリプロセッサ マクロに切り捨てられます。
すべてのコンストラクターは、複数のセットを初期化します。
すべてのコンストラクターは複数のセットのキーの間の順序を確立するために使用される key_compを呼び出して後で、型の比較関数オブジェクトを格納します。
明示的に使用されるアロケーターの型 (_Al) を指定する最初の 3 のコンストラクターは、空の初期複数のセットを指定し、2 番目の要素と番目の順序の確立に使用する比較関数 (_Comp) の型を指定します。キーワード explicit は、特定の種類の自動型変換を抑制します。
4 つ目のコンストラクターは、_Rightセットのコピーを指定します。
次の 3 種類のコンストラクターは、比較関数とアロケーターの型の指定を大きくする explicitness 複数のセットの範囲 [_First、_Last) をコピーします。
最後のコンストラクターは、を移動 _Rightセットによって複数のコピーを指定します。
使用例
// multiset_ctor.cpp
// compile with: /EHsc
#include <set>
#include <iostream>
int main( )
{
using namespace std;
multiset <int>::iterator ms1_Iter, ms2_Iter, ms3_Iter;
multiset <int>::iterator ms4_Iter, ms5_Iter, ms6_Iter, ms7_Iter;
// Create an empty multiset ms0 of key type integer
multiset <int> ms0;
// Create an empty multiset ms1 with the key comparison
// function of less than, then insert 4 elements
multiset <int, less<int> > ms1;
ms1.insert( 10 );
ms1.insert( 20 );
ms1.insert( 20 );
ms1.insert( 40 );
// Create an empty multiset ms2 with the key comparison
// function of geater than, then insert 2 elements
multiset <int, greater<int> > ms2;
ms2.insert( 10 );
ms2.insert( 20 );
// Create a multiset ms3 with the
// allocator of multiset ms1
multiset <int>::allocator_type ms1_Alloc;
ms1_Alloc = ms1.get_allocator( );
multiset <int> ms3( less<int>( ), ms1_Alloc );
ms3.insert( 30 );
// Create a copy, multiset ms4, of multiset ms1
multiset <int> ms4( ms1 );
// Create a multiset ms5 by copying the range ms1[_First, _Last)
multiset <int>::const_iterator ms1_bcIter, ms1_ecIter;
ms1_bcIter = ms1.begin( );
ms1_ecIter = ms1.begin( );
ms1_ecIter++;
ms1_ecIter++;
multiset <int> ms5( ms1_bcIter, ms1_ecIter );
// Create a multiset ms6 by copying the range ms4[_First, _Last)
// and with the allocator of multiset ms2
multiset <int>::allocator_type ms2_Alloc;
ms2_Alloc = ms2.get_allocator( );
multiset <int> ms6( ms4.begin( ), ++ms4.begin( ), less<int>( ), ms2_Alloc );
cout << "ms1 =";
for ( ms1_Iter = ms1.begin( ); ms1_Iter != ms1.end( ); ms1_Iter++ )
cout << " " << *ms1_Iter;
cout << endl;
cout << "ms2 = " << *ms2.begin( ) << " " << *++ms2.begin( )
<< endl;
cout << "ms3 =";
for ( ms3_Iter = ms3.begin( ); ms3_Iter != ms3.end( ); ms3_Iter++ )
cout << " " << *ms3_Iter;
cout << endl;
cout << "ms4 =";
for ( ms4_Iter = ms4.begin( ); ms4_Iter != ms4.end( ); ms4_Iter++ )
cout << " " << *ms4_Iter;
cout << endl;
cout << "ms5 =";
for ( ms5_Iter = ms5.begin( ); ms5_Iter != ms5.end( ); ms5_Iter++ )
cout << " " << *ms5_Iter;
cout << endl;
cout << "ms6 =";
for ( ms6_Iter = ms6.begin( ); ms6_Iter != ms6.end( ); ms6_Iter++ )
cout << " " << *ms6_Iter;
cout << endl;
// Create a set by moving s5
set<int> ms7(move(ms5));
cout << "ms7 =";
for ( ms7_Iter = ms7.begin( ); ms7_Iter != ms7.end( ); ms7_Iter++ )
cout << " " << *ms7_Iter;
cout << endl;
}
出力
ms1 = 10 20 20 40
ms2 = 20 10
ms3 = 30
ms4 = 10 20 20 40
ms5 = 10 20
ms6 = 10
ms7 = 10 20
必要条件
ヘッダー: <set>
名前空間: std