Architecture Diagram
MULTIMAP TREE NODES:
Key: "error" ──► "Disk full"
Key: "error" ──► "Connection timed out"
Key: "info" ──► "System started"
Key: "warn" ──► "High memory usage"MULTIMAP TREE NODES:
Key: "error" ──► "Disk full"
Key: "error" ──► "Connection timed out"
Key: "info" ──► "System started"
Key: "warn" ──► "High memory usage"equal_range(k): Returns std::pair bounding all matching keys in $O(\log N)$.count(k): Returns the number of occurrences of key k.#include <iostream>
#include <map>
#include <string>
int main() {
std::multimap<std::string, std::string> phoneBook;
phoneBook.insert({"Alice", "+1-555-0101"});
phoneBook.insert({"Alice", "+1-555-0999"}); // Second number for Alice
phoneBook.insert({"Bob", "+1-555-0202"});
phoneBook.insert({"Alice", "+1-555-1234"}); // Third number
std::cout << "All Numbers for Alice (using equal_range):\n";
auto [start, end] = phoneBook.equal_range("Alice");
for (auto it = start; it != end; ++it) {
std::cout << " - " << it->first << ": " << it->second << "\n";
}
std::cout << "Total numbers registered for Alice: " << phoneBook.count("Alice") << "\n";
return 0;
}.equal_range() rather than separate .lower_bound() and .upper_bound() calls to avoid redundant tree traversals.std::multimap for one-to-many relationship modeling (e.g. tag-to-articles, category-to-products)..insert() or .emplace() since operator[] is not provided.