#include "treemap.h" #include struct account_t { double balance; std::string note; account_t() : account_t { 0.0 } { } account_t(double balance) : balance { balance } { } }; struct lanister_t { std::string name; lanister_t() { } lanister_t(const char* name) : name { name } { } bool operator < (const lanister_t& lanister) const { return name < lanister.name; } bool operator == (const lanister_t& lanister) const { return name == lanister.name; } }; std::ostream& operator << (std::ostream& os, const lanister_t& lanister) { os << lanister.name << " Lanister"; return os; } std::ostream& operator << (std::ostream& os, const account_t& account) { os << account.balance << "€"; if(account.note.length() > 0) os << " (" << account.note << ")"; return os; } int main(int argc, char* argv[]) { treemap_t map; //std::map map; map["Tyrion"] = 2; map["Jaime"] = 15; map["Cersei"] = 63; map["Tywin"] = 75; map["Kevan"] = 48; map["Lancel"] = 70; map["Alton"] = 54; map["Martyn"] = 32; map["Willem"] = 6; map["Tyrion"].note = "best client ever"; std::cout << ":: " << map.at("Kevan") << std::endl; std::cout << "=====" << std::endl; map.display(); std::cout << "=====" << std::endl; for(auto& [key, value]: map) std::cout << "(" << key << ", " << value << ")" << std::endl; std::cout << "-------------------------" << std::endl; // more tests treemap_t map_int_str; treemap_t map_int_int; treemap_t map_str_str; //int tab[] = { 1, 2, 3, 4, 5, 6, 7 }; int tab[] = { 4, 3, 1, 2, 5, 6, 7 }; //int tab[] = { 7, 6, 5, 4, 3, 2, 1 }; for(size_t i=0; i