/
githubmirror
/
CPlusPlusThings
Обзор
Документация
Войти
/
githubmirror
/
CPlusPlusThings
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
learn_class/modern_cpp_30/container2/relacontainer.cpp
57 строк
1 KB
zhangxing
support bazel complie this project and format code.
30 мар 2024, 17:00
30 мар 2024, 17:00
3c8a3f2
Код
Авторство
О чём код?
// // Created by light on 19-12-16. // #include "../container1/output_container.h" #include <functional> #include <iostream> #include <map> #include <set> #include <string> #include <tuple> using namespace std; int main() { set<int> s{1, 1, 1, 2, 3, 4}; cout << s << endl; multiset<int, greater<int>> ms{1, 1, 1, 2, 3, 4}; cout << ms << endl; map<string, int> mp{{"one", 1}, {"two", 2}, {"three", 3}, {"four", 4}}; cout << mp << endl; mp.insert({"four", 4}); cout << mp << endl; cout << (mp.find("four") == mp.end()) << endl; cout << (mp.find("five") == mp.end()) << endl; mp["five"] = 5; cout << mp << endl; multimap<string, int> mmp{{"one", 1}, {"two", 2}, {"three", 3}, {"four", 4}}; cout << mmp << endl; mmp.insert({"four", -4}); cout << mmp << endl; cout << (mp.find("four")->second) << endl; cout << (mp.lower_bound("four")->second) << endl; cout << (mp.upper_bound("four")->second) << endl; cout << ((--mp.upper_bound("four"))->second) << endl; multimap<string, int>::iterator lower, upper; std::tie(lower, upper) = mmp.equal_range("four"); cout << (lower != upper) << endl; // 检测区间非空 cout << lower->second << endl; cout << (--upper)->second << endl; }