例を使用したC++STLのマルチセットmax_size()
このチュートリアルでは、C ++ STLのマルチセットmax_size()を理解するためのプログラムについて説明します。
関数max_size()は、特定のコンテナが保持できる要素の最大数を返します。
例
#include <bits/stdc++.h>
using namespace std;
int main(){
multiset<int> s;
s.insert(10);
s.insert(13);
s.insert(13);
s.insert(25);
s.insert(24);
cout << "The multiset elements are: ";
for (auto it = s.begin(); it != s.end(); it++)
cout << *it << " ";
cout << "\nThe max size of multiset: " << s.max_size();
return 0;
} 出力
The multiset elements are: 10 13 13 24 25 The max size of multiset: 461168601842738790
-
C ++ STLのマルチセットinsert()関数
C ++ STLのマルチセットinsert()関数は、マルチセットコンテナ内の要素を、あるマルチセットから別のマルチセットのある位置から別の位置に挿入します。 使用されている関数のリスト: ms.size()=マルチセットのサイズを返します。 ms.insert()=マルチセットに要素を挿入するために使用されます。 サンプルコード #include <iostream> #include <set> #include <string> #include <cstdlib> using namespace std; int main()
-
STLにマルチセットを実装するC++プログラム
マルチセットは、複数の要素が同じ値を持つことができる連想コンテナの一種です。 機能と説明: Functions are used here: ms.size() = Returns the size of multiset. ms.insert) = It is used to insert elements to the multiset. ms.erase() = Removes the value from the multiset. ms.find() = Returns an it