Skip to content

Instantly share code, notes, and snippets.

@yanhsiah
Created October 13, 2019 23:25
Show Gist options
  • Save yanhsiah/2f3e3f91cae525112054d91bfbcb47b9 to your computer and use it in GitHub Desktop.
Save yanhsiah/2f3e3f91cae525112054d91bfbcb47b9 to your computer and use it in GitHub Desktop.
priority_queue
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