/* * dictionary.h * * Created on: 23.01.2014 * Author: trifon */ #ifndef DICTIONARY_H_ #define DICTIONARY_H_ #include "linked_list.cpp" template class Dictionary { virtual V* search(K const&) = 0; virtual bool add(K const&, V const& ) = 0; virtual bool remove(K const&, V&) = 0; virtual LinkedList keys() const = 0; }; template struct KeyValuePair { K key; V value; KeyValuePair(K const& k = K(), V const& v = V()) : key(k), value(v) {} bool operator==(KeyValuePair const& kvp) const { return key == kvp.key; } bool operator!=(KeyValuePair const& kvp) const { return !(*this == kvp); } bool operator<(KeyValuePair const& kvp) const { return key < kvp.key; } bool operator>=(KeyValuePair const& kvp) const { return !(*this < kvp); } bool operator<=(KeyValuePair const& kvp) const { return *this < kvp || *this == kvp; } bool operator>(KeyValuePair const& kvp) const { return !(*this <= kvp); } friend ostream& operator<<(ostream& os, KeyValuePair const& kvp) { return os << '(' << kvp.key << " -> " << kvp.value << ')' << endl; } }; #endif /* DICTIONARY_H_ */