13.mutiset樹每一個結點都是一個鏈表的指針,可以存儲相同的數據
阿新 • • 發佈:2018-03-23
air include 頭結點 fin names body 指針 cst cin
1 #include <iostream> 2 //紅黑樹(自動保證平衡,自動生成平衡查找樹) 3 #include <set> 4 #include <cstring> 5 #include <cstdlib> 6 using namespace std; 7 8 9 void main() 10 { 11 //紅黑樹,每一個結點都是一個鏈表的頭結點 12 multiset<int> myset{ 1,2,3,3,3,3,4 }; 13 myset.insert(101); 14 myset.insert(101); 15 16 for (auto i : myset) 17 { 18 cout << i << endl; 19 } 20 21 //找到一個 22 auto ifind = myset.find(101); 23 24 //找到所有 25 auto it = myset.equal_range(3); 26 //輸出類型 27 //cout << typeid(it).name() << endl; 28 29 //類型是pair first是起點,second是終點30 for (auto i = it.first; i != it.second; i++) 31 { 32 cout << *i << endl; 33 } 34 35 cin.get(); 36 }
13.mutiset樹每一個結點都是一個鏈表的指針,可以存儲相同的數據