/* */ #include "Dictionary.h" #include "MetaEntryVisitor.h" #include namespace aria2 { Dictionary::Dictionary() {} Dictionary::~Dictionary() { clearTable(); } void Dictionary::clearTable() { for(std::map::iterator itr = table.begin(); itr != table.end(); itr++) { delete itr->second; } table.clear(); } const MetaEntry* Dictionary::get(const std::string& name) const { std::map::const_iterator itr = table.find(name); if(itr == table.end()) { return NULL; } else { return itr->second; } } void Dictionary::put(const std::string& name, MetaEntry* entry) { table[name] = entry; order.push_back(name); } void Dictionary::remove(const std::string& name) { std::map::iterator i = table.find(name); if(i != table.end()) { delete i->second; table.erase(i); order.erase(std::remove(order.begin(), order.end(), name), order.end()); } } void Dictionary::accept(MetaEntryVisitor* v) const { v->visit(this); } const std::deque& Dictionary::getOrder() const { return order; } } // namespace aria2