Created
October 13, 2019 23:25
-
-
Save yanhsiah/2f3e3f91cae525112054d91bfbcb47b9 to your computer and use it in GitHub Desktop.
priority_queue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
priority_queue<string> pqZtoA; | |
pqZtoA.push("hello"); pqZtoA.push("word"); | |
unordered_map<string, priority_queue<string>> mpZtoA; | |
mpZtoA["key"] = pqZtoA; | |
mpZtoA["key"].push("allen"); | |
while (!mpZtoA["key"].empty()) { | |
cout << mpZtoA["key"].top() << ", "; | |
mpZtoA["key"].pop(); | |
} | |
cout << endl; | |
// word, hello, allen, | |
priority_queue<string, vector<string>, greater<string>> pqAtoZ; | |
pqAtoZ.push("hello"); pqAtoZ.push("word"); | |
unordered_map<string, priority_queue<string, vector<string>, greater<string>>> mpAtoZ; | |
mpAtoZ["key"] = pqAtoZ; | |
mpAtoZ["key"].push("allen"); | |
while (!mpAtoZ["key"].empty()) { | |
cout << mpAtoZ["key"].top() << ", "; | |
mpAtoZ["key"].pop(); | |
} | |
cout << endl; | |
// allen, hello, word, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment