CircularQueue.hpp
上传用户:afrynkmhm
上传日期:2007-01-06
资源大小:1262k
文件大小:2k
源码类别:

编译器/解释器

开发平台:

Others

  1. #ifndef INC_CircularQueue_hpp__
  2. #define INC_CircularQueue_hpp__
  3. /**
  4.  * <b>SOFTWARE RIGHTS</b>
  5.  * <p>
  6.  * ANTLR 2.6.0 MageLang Insitute, 1999
  7.  * <p>
  8.  * We reserve no legal rights to the ANTLR--it is fully in the
  9.  * public domain. An individual or company may do whatever
  10.  * they wish with source code distributed with ANTLR or the
  11.  * code generated by ANTLR, including the incorporation of
  12.  * ANTLR, or its output, into commerical software.
  13.  * <p>
  14.  * We encourage users to develop software with ANTLR. However,
  15.  * we do ask that credit is given to us for developing
  16.  * ANTLR. By "credit", we mean that if you use ANTLR or
  17.  * incorporate any source code into one of your programs
  18.  * (commercial product, research project, or otherwise) that
  19.  * you acknowledge this fact somewhere in the documentation,
  20.  * research report, etc... If you like ANTLR and have
  21.  * developed a nice tool with the output, please mention that
  22.  * you developed it using ANTLR. In addition, we ask that the
  23.  * headers remain intact in our source code. As long as these
  24.  * guidelines are kept, we expect to continue enhancing this
  25.  * system and expect to make other tools available as they are
  26.  * completed.
  27.  * <p>
  28.  * The ANTLR gang:
  29.  * @version ANTLR 2.6.0 MageLang Insitute, 1999
  30.  * @author Terence Parr, <a href=http://www.MageLang.com>MageLang Institute</a>
  31.  * @author <br>John Lilley, <a href=http://www.Empathy.com>Empathy Software</a>
  32.  * @author <br><a href="mailto:pete@yamuna.demon.co.uk">Pete Wells</a>
  33.  */
  34. #include "antlr/config.hpp"
  35. #include <vector>
  36. ANTLR_BEGIN_NAMESPACE(antlr)
  37. template <class T>
  38. class CircularQueue {
  39. private:
  40. typename ANTLR_USE_NAMESPACE(std)vector<T> storage;
  41. public:
  42. CircularQueue()
  43. : storage() {}
  44. ~CircularQueue()
  45. {}
  46. T elementAt(int idx) const
  47. { return storage[idx]; }
  48. void removeFirst()
  49. { if (storage.size()>0) storage.erase(storage.begin()); }
  50. void append(const T& t)
  51. { storage.push_back(t); }
  52. int entries() const
  53. { return storage.size(); }
  54. private:
  55. CircularQueue(const CircularQueue&);
  56. const CircularQueue& operator=(const CircularQueue&);
  57. };
  58. ANTLR_END_NAMESPACE
  59. #endif //INC_CircularQueue_hpp__