template<class K, class V> class Map {
    friend class Mapiter<K,V>;
    Link<K,V>* head;
    Link<K,V>* current;
    V def_val;
    K def_key;
    int sz;
    static K kdef(); // default K value 
    static V vdef(); // default V value
    void find(const K&);
    void init() { sz = 0; head = 0; current = 0; }
public:
    Map() : def_key(kdef()), def_val(vdef())
	{ init(); }
    Map(const K& k, const V& d) : def_key(k), def_val(d)
	{ init(); }
    ~Map() { delete head; } // delete all links recursively
    Map(const Map&);
    Map& operator= (const Map&);
    V& operator[] (const K&);
    int size() const { return sz; }
    void clear() { delete head; init(); }
    void remove(const K& k);
	// iteration functions:
    Mapiter<K,V> element(const K& k)
    {
	(void) operator[](k);  // move current to k
	return Mapiter<K,V>(this,current);
    }
    Mapiter<K,V> first() { return Mapiter<K,V>(this,head); }
    Mapiter<K,V> last();
};
template<class K, class V> K Map<K,V>::kdef()
    { static K k; return k; }
template<class K, class V> V Map<K,V>::vdef()
    { static V v; return v; }