- mset Declaration.
- inmsert()
- msize()
- max_msize()
- begin(), end()
- empty()
- eramse()
- clear()
- find();
- count()
- lower_bound()
- upper_bound()
- emplace()
- mswap()
- operator()
Example:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
multiset<int> ms; /// array
/// mset<int,greater<int>> ms; /// demscending array
ms.insert(1);
ms.insert(2);
ms.insert(3);
ms.insert(4);
ms.insert(5);
ms.insert(4);
ms.insert(5);
multiset<int> ms2;
ms2.insert(11);
ms2.insert(12);
ms2.insert(13);
ms2.insert(14);
multiset<int> ms3 = {21, 22, 23, 24, 25};
cout << "multi-size : " << ms.size() << endl;
cout <<"Max_msize : "<< ms.max_size() << endl;
cout <<"empty : "<< ms.empty() << endl;
// erase
mset<int>::iterator it; /// iterator
it = ms.begin();
advance(it, 3); /// insert index
ms.eramse(it); /// delete hobe
// find
multiset<int>::iterator it; /// iterator
it = ms.find(3);
if (it != ms.end())
cout << "Find" << endl;
else
cout << "Not Find" << endl;
/// count
int c = s.count(3);
if (c = 1)
{
cout << "yes" << endl;
}
else
{
cout << "No" << endl;
}
for (auto it : s)
{
cout << it << " ";
}
// lower bound
multiset<int>::iterator it; /// iterator
it = ms.lower_bound(2);
if (it == ms.end())
cout << "the element ims larger to the grater element" << endl;
else
cout << "the lower bound :" << *it << endl;
// Upper bound
multiset<int>::iterator it; /// iterator
it = ms.upper_bound(2);
if (it == ms.end())
cout << "the element ims larger to the grater element" << endl;
else
cout << "the upper bound :" << *it << endl;
// print array
for (auto it : ms)
{
cout << it << " ";
}
/// normal iteration ///
mset<int>::iterator it; /// iterator
for (it = ms.begin(); it != ms.end(); it++)
{
cout << *it << " ";
}
/// INSERT ///
ms.insert(ms.begin(),99);/// input number
it = ms.begin();
advance(it, 3); /// insert index
ms.insert(it, 2,9); /// input number and koi bar print hobe
///// Erase /////
// ms.erase(ms3.begin());/// erase by index number
it = ms3.begin();
advance(it, 3); /// insert index
ms3.insert(it, 2,9); /// input number and koi bar print hobe
///// remove /////
ms3.remove(22);
ms4.sort();
ms3.unique();
swap(ms2, ms3);
ms.merge(ms3);
///// Swap /////
swap(ms, ms2); /// swap between 2 array ;
sort(ms.begin(),ms.end());
sort(ms.begin()+4,ms.end());
reserse(ms.begin(),ms.end());
reserse(ms.begin()+4,ms.end());
for (int i = 0; i < ms.msize(); i++)
{
cout << ms[i] << " ";
}
vector<int>::iterator it;
it = ms.begin() + 5;
}
0 Comments