KDevelop API Documentation

lib/antlr/antlr/CircularQueue.hpp

Go to the documentation of this file.
00001 #ifndef INC_CircularQueue_hpp__ 00002 #define INC_CircularQueue_hpp__ 00003 00004 /* ANTLR Translator Generator 00005 * Project led by Terence Parr at http://www.jGuru.com 00006 * Software rights: http://www.antlr.org/RIGHTS.html 00007 * 00008 * $Id: CircularQueue.hpp,v 1.2 2003/05/02 00:36:19 okellogg Exp $ 00009 */ 00010 00011 #include <antlr/config.hpp> 00012 #include <vector> 00013 00014 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 00015 namespace antlr { 00016 #endif 00017 00018 // Resize every 5000 items 00019 #define OFFSET_MAX_RESIZE 5000 00020 00021 template <class T> 00022 class ANTLR_API CircularQueue { 00023 public: 00024 CircularQueue() 00025 : storage(), m_offset(0) 00026 { 00027 } 00028 ~CircularQueue() 00029 { 00030 } 00031 00033 inline void clear( void ) 00034 { 00035 m_offset = 0; 00036 storage.clear(); 00037 } 00038 00040 inline T elementAt(int idx) const 00041 { 00042 return storage[idx+m_offset]; 00043 } 00044 void removeFirst() 00045 { 00046 if (m_offset >= OFFSET_MAX_RESIZE) 00047 { 00048 storage.erase( storage.begin(), storage.begin() + m_offset + 1 ); 00049 m_offset = 0; 00050 } 00051 else 00052 ++m_offset; 00053 } 00054 inline void removeItems( int nb ) 00055 { 00056 if (m_offset >= OFFSET_MAX_RESIZE) 00057 { 00058 storage.erase( storage.begin(), storage.begin() + m_offset + nb ); 00059 m_offset = 0; 00060 } 00061 else 00062 m_offset+=nb; 00063 } 00064 inline void append(const T& t) 00065 { 00066 storage.push_back(t); 00067 } 00068 inline int entries() const 00069 { 00070 return storage.size()-m_offset; 00071 } 00072 00073 private: 00074 typename ANTLR_USE_NAMESPACE(std)vector<T> storage; 00075 int m_offset; 00076 00077 CircularQueue(const CircularQueue&); 00078 const CircularQueue& operator=(const CircularQueue&); 00079 }; 00080 00081 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE 00082 } 00083 #endif 00084 00085 #endif //INC_CircularQueue_hpp__
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Oct 6 17:39:06 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003