association.h

来自「用于词法分析的词法分析器」· C头文件 代码 · 共 51 行

H
51
字号
/*  $Id: Association.h,v 1.2 1997/02/02 01:31:04 matt Exp $  Associations.  (c) May 95 Matt Phillips  */#ifndef _ASSOC_H#define _ASSOC_H#include "ContainerPresentation.h"template <class K, class T>class AssociationIter : public ContainerIter<T>{public:  virtual const K &getKey () const = 0;};template <class K, class T>class Association : public ContainerPresentation<T>{public:     virtual const char *name () const {return "Association";}     virtual T &add (K &key, T &i) = 0;  virtual int remove (const K &key) = 0;  int exists (const K &key) const {return get (key) != 0;}  virtual T *get (const K &key) const = 0;  virtual AssociationIter<K, T> *makeIter () const = 0;  virtual void printTo (ostream &os) const;};template <class K, class T>void Association<K, T>::printTo (ostream &os) const{  AssociationIter<K, T> *i;     os << name () << endl;     for (i = makeIter (); *i; (*i)++)    os << "  " << i->getKey () << " -> " << i->ref () << endl;     delete i;}#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?