1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/********************************************
DISCLAIMER:
This is a wrapper code to mimic the relevant std:: class
Please use it ONLY when porting an existing code e.g. from the original sources
For all new development please use classes from Common::
*********************************************/
#ifndef COMMON_STD_QUEUE_H
#define COMMON_STD_QUEUE_H
#include "common/std/algorithm.h"
#include "common/std/vector.h"
#include "common/queue.h"
namespace Std {
template<class T>
using queue = Common::Queue<T>;
/**
* FIXME: The current implementation requires the reverse
* greater/lesser comparitor than the original does.
* If this is fixed, also change the router finder's use
*/
template<class T, class Container = vector<T>, class Comparitor = typename Common::Less<T> >
class priority_queue {
private:
Container _container;
Comparitor _comparitor;
public:
priority_queue() {}
bool empty() const {
return _container.empty();
}
const T &top() const {
return _container.front();
}
void push(const T &item) {
_container.push_back(item);
Common::sort(_container.begin(), _container.end(), _comparitor);
}
void pop() {
_container.remove_at(0);
}
};
template<class T>
class deque {
private:
vector<T> _intern;
public:
deque() = default;
typedef typename vector<T>::iterator iterator;
typedef const typename vector<T>::const_iterator const_iterator;
typedef typename vector<T>::reverse_iterator reverse_iterator;
typedef const typename vector<T>::const_reverse_iterator const_reverse_iterator;
void clear() {
_intern.clear();
}
void insert(const T &item) {
_intern.push_back(item);
}
void push_back(const T &item) {
_intern.push_back(item);
}
void push_front(const T &item) {
_intern.push_front(item);
}
void pop_back() {
_intern.pop_back();
}
void pop_front() {
_intern.remove_at(0);
}
const T &front() const {
return _intern.front();
}
const T &back() const {
return _intern.back();
}
void resize(size_t newSize) {
_intern.resize(newSize);
}
size_t size() const {
return _intern.size();
}
T at(size_t idx) {
return _intern[idx];
}
const_iterator cbegin() {
return _intern.cbegin();
}
const_iterator cend() {
return _intern.cend();
}
reverse_iterator rbegin() {
return _intern.rbegin();
}
reverse_iterator rend() {
return _intern.rend();
}
const_reverse_iterator rbegin() const {
return _intern.rbegin();
}
const_reverse_iterator rend() const {
return _intern.rend();
}
const_reverse_iterator crbegin() const {
return _intern.crbegin();
}
const_reverse_iterator crend() const {
return _intern.crend();
}
};
} // namespace Std
#endif
|