1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef COMMON_QUEUE_H 24 #define COMMON_QUEUE_H 25 26 #include "common/scummsys.h" 27 #include "common/list.h" 28 29 namespace Common { 30 31 /** 32 * @defgroup common_queue Queue 33 * @ingroup common 34 * 35 * @brief API and templates for queues. 36 * @{ 37 */ 38 39 /** 40 * Variable size Queue class, implemented using our List class. 41 */ 42 template<class T> 43 class Queue { 44 //public: 45 // typedef T value_type; 46 47 public: empty()48 bool empty() const { 49 return _impl.empty(); 50 } 51 clear()52 void clear() { 53 _impl.clear(); 54 } 55 push(const T & x)56 void push(const T &x) { 57 _impl.push_back(x); 58 } 59 front()60 T &front() { 61 return _impl.front(); 62 } 63 front()64 const T &front() const { 65 return _impl.front(); 66 } 67 back()68 T &back() { 69 return _impl.back(); 70 } 71 back()72 const T &back() const { 73 return _impl.back(); 74 } 75 pop()76 T pop() { 77 T tmp = front(); 78 _impl.pop_front(); 79 return tmp; 80 } 81 size()82 int size() const { 83 return _impl.size(); 84 } 85 86 private: 87 List<T> _impl; 88 }; 89 90 /** @} */ 91 92 } // End of namespace Common 93 94 #endif 95