ScummVM API documentation
queue.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef COMMON_QUEUE_H
23 #define COMMON_QUEUE_H
24 
25 #include "common/scummsys.h"
26 #include "common/list.h"
27 
28 namespace Common {
29 
41 template<class T>
42 class Queue {
43 //public:
44 // typedef T value_type;
45 
46 public:
47  bool empty() const {
48  return _impl.empty();
49  }
50 
51  void clear() {
52  _impl.clear();
53  }
54 
55  void push(const T &x) {
56  _impl.push_back(x);
57  }
58 
59  T &front() {
60  return _impl.front();
61  }
62 
63  const T &front() const {
64  return _impl.front();
65  }
66 
67  T &back() {
68  return _impl.back();
69  }
70 
71  const T &back() const {
72  return _impl.back();
73  }
74 
75  T pop() {
76  T tmp = front();
77  _impl.pop_front();
78  return tmp;
79  }
80 
81  int size() const {
82  return _impl.size();
83  }
84 
85 private:
86  List<T> _impl;
87 };
88 
91 } // End of namespace Common
92 
93 #endif
void pop_front()
Definition: list.h:145
size_type size() const
Definition: list.h:198
Definition: queue.h:42
t_T & back()
Definition: list.h:167
Definition: algorithm.h:29
void clear()
Definition: list.h:206
t_T & front()
Definition: list.h:157
void push_back(const t_T &element)
Definition: list.h:140
bool empty() const
Definition: list.h:219