#ifndef MAP #define MAP #include #include using namespace std; template class myvector: public vector { }; //KEY must be copy constructable and equality comparable. //VALUE must be copy constructable. //CONTAINER must have const_iterator, begin, end, push_back. template class CONTAINER = myvector> class map { CONTAINER key; CONTAINER value; public: const VALUE& find(const KEY& k) const { typename CONTAINER::const_iterator itv = value.begin(); for (typename CONTAINER::const_iterator itk = key.begin(); itk != key.end(); ++itk, ++itv) { if (*itk == k) { return *itv; } } cerr << "key not found\n"; exit(EXIT_FAILURE); } void insert(const KEY& k, const VALUE& v) { key .push_back(k); value.push_back(v); } }; #endif