Isle
Loading...
Searching...
No Matches
mxstl.h
Go to the documentation of this file.
1// clang-format off
2
3#ifndef MXSTL_H
4#define MXSTL_H
5
6#include <use_ansi.h>
7#include <algorithm>
8#include <deque>
9#include <functional>
10#include <iterator>
11#include <list>
12#include <map>
13#include <memory>
14#include <numeric>
15#include <queue>
16#include <set>
17#include <stack>
18#include <utility>
19#include <vector>
20
21
22#ifdef _MSC_VER
23/*
24 * Currently, all MS C compilers for Win32 platforms default to 8 byte
25 * alignment.
26 */
27#pragma pack(push,8)
28#endif // _MSC_VER
29
35template<class _TYPE>
36class Deque : public deque<_TYPE, allocator<_TYPE> >
37{
38public:
40 typedef allocator<_TYPE> _A;
41
46 explicit Deque(const _A& _Al = _A()) : deque<_TYPE, _A>(_Al)
47 {}
48
54 explicit Deque(size_type _N, const _TYPE& _V = _TYPE()) : deque<_TYPE, _A>(_N, _V)
55 {}
56
61 void swap(_Myt& _X)
62 {
63 deque<_TYPE, _A>::swap((deque<_TYPE, _A>&)_X);
64 }
65
71 friend void swap(_Myt& _X, _Myt& _Y)
72 {
73 _X.swap(_Y);
74 }
75};
76
82template<class _TYPE>
83class List : public list<_TYPE, allocator<_TYPE> >
84{
85public:
86 typedef List<_TYPE> _Myt;
87 typedef allocator<_TYPE> _A;
88
92 explicit List() : list<_TYPE, _A>()
93 {}
94
100 explicit List(size_type _N, const _TYPE& _V = _TYPE()) : list<_TYPE, _A>(_N, _V)
101 {}
102
107 void swap(_Myt& _X)
108 {
109 list<_TYPE, _A>::swap((list<_TYPE, _A>&)_X);
110 }
111
117 friend void swap(_Myt& _X, _Myt& _Y)
118 {
119 _X.swap(_Y);
120 }
121};
122
128template<class _K, class _TYPE, class _Pr>
129class Map : public map<_K, _TYPE, _Pr, allocator<_TYPE> >
130{
131public:
133 typedef allocator<_TYPE> _A;
134
139 explicit Map(const _Pr& _Pred = _Pr())
140 : map<_K, _TYPE, _Pr, _A>(_Pred)
141 {}
142
147 void swap(_Myt& _X)
148 {
149 map<_K, _TYPE, _Pr, _A>::swap((map<_K, _TYPE, _Pr, _A>&)_X);
150 }
151
157 friend void swap(_Myt& _X, _Myt& _Y)
158 {
159 _X.swap(_Y);
160 }
161};
162
168template<class _K, class _TYPE, class _Pr>
169class Multimap : public multimap<_K, _TYPE, _Pr, allocator<_TYPE> >
170{
171public:
173 typedef allocator<_TYPE> _A;
174
179 explicit Multimap(const _Pr& _Pred = _Pr()) : multimap<_K, _TYPE, _Pr, _A>(_Pred)
180 {}
181
186 void swap(_Myt& _X)
187 {
188 multimap<_K, _TYPE, _Pr, _A>::swap((multimap<_K, _TYPE, _Pr, _A>&)_X);
189 }
190
196 friend void swap(_Myt& _X, _Myt& _Y)
197 {
198 _X.swap(_Y);
199 }
200};
201
207template<class _K, class _Pr>
208class Set : public set<_K, _Pr, allocator<_K> >
209{
210public:
212 typedef allocator<_K> _A;
213
218 explicit Set(const _Pr& _Pred = _Pr()) : set<_K, _Pr, _A>(_Pred)
219 {}
220
225 void swap(_Myt& _X)
226 {
227 set<_K, _Pr, _A>::swap((set<_K, _Pr, _A>&)_X);
228 }
229
235 friend void swap(_Myt& _X, _Myt& _Y)
236 {
237 _X.swap(_Y);
238 }
239};
240
246template<class _K, class _Pr>
247class Multiset : public multiset<_K, _Pr, allocator<_K> >
248{
249public:
251 typedef allocator<_K> _A;
252
257 explicit Multiset(const _Pr& _Pred = _Pr())
258 : multiset<_K, _Pr, _A>(_Pred)
259 {}
260
265 void swap(_Myt& _X)
266 {
267 multiset<_K, _Pr, _A>::swap((multiset<_K, _Pr, _A>&)_X);
268 }
269
275 friend void swap(_Myt& _X, _Myt& _Y)
276 {
277 _X.swap(_Y);
278 }
279};
280
286template<class _TYPE>
287class Vector : public vector<_TYPE, allocator<_TYPE> >
288{
289public:
291 typedef allocator<_TYPE> _A;
292
297 explicit Vector(const _A& _Al = _A()) : vector<_TYPE, _A>(_Al)
298 {}
299
304 void swap(_Myt& _X)
305 {
306 vector<_TYPE, _A>::swap((vector<_TYPE, _A>&)_X);
307 }
308
314 friend void swap(_Myt& _X, _Myt& _Y)
315 {
316 _X.swap(_Y);
317 }
318};
319
325template<class _C, class _Pr>
326class Priority_queue : public priority_queue<_C::value_type, _C, _Pr, _C::allocator_type>
327{
328public:
329 typedef _C::value_type _TYPE;
330 typedef _C::allocator_type _A;
331 typedef _C::allocator_type allocator_type;
332
338 explicit Priority_queue(const _Pr& _X = _Pr(), const _C::allocator_type& _Al = _C::allocator_type()) : priority_queue<_C::value_type, _C, _Pr, _C::allocator_type>(_X, _Al)
339 {}
340};
341
347template<class _C>
348class Queue : public queue<_C::value_type, _C, _C::allocator_type>
349{};
350
356template<class _C>
357class Stack : public stack<_C::value_type, _C, _C::allocator_type>
358{};
359
409#define deque Deque
410#define list List
411#define map Map
412#define multimap Multimap
413#define set Set
414#define multiset Multiset
415#define vector Vector
416#define priority_queue Priority_queue
417#define queue Queue
418#define stack Stack
419
420#ifdef _MSC_VER
421#pragma pack(pop)
422#endif
423
424#endif // MXSTL_H
425
426// clang-format on
[AI] Custom wrapper around std::deque providing consistent allocator usage and swap semantics.
Definition: mxstl.h:37
Deque(const _A &_Al=_A())
[AI] Constructs a Deque with an optional allocator.
Definition: mxstl.h:46
Deque< _TYPE > _Myt
[AI] Self type for use in member functions and templates. [AI]
Definition: mxstl.h:39
allocator< _TYPE > _A
[AI] Allocator type for contained elements. [AI]
Definition: mxstl.h:40
friend void swap(_Myt &_X, _Myt &_Y)
[AI] Friend swap function for ADL-enabled efficient swapping.
Definition: mxstl.h:71
void swap(_Myt &_X)
[AI] Swaps the contents of this Deque with another.
Definition: mxstl.h:61
Deque(size_type _N, const _TYPE &_V=_TYPE())
[AI] Constructs a Deque with a specified number of elements and initial value.
Definition: mxstl.h:54
[AI] Custom wrapper around std::list providing consistent allocator usage and swap semantics.
Definition: mxstl.h:84
void swap(_Myt &_X)
[AI] Swaps the contents of this List with another.
Definition: mxstl.h:107
allocator< _TYPE > _A
[AI] Allocator type. [AI]
Definition: mxstl.h:87
List< _TYPE > _Myt
[AI] Self type for member use. [AI]
Definition: mxstl.h:86
List()
[AI] Constructs an empty List.
Definition: mxstl.h:92
friend void swap(_Myt &_X, _Myt &_Y)
[AI] Friend swap for efficient List swapping.
Definition: mxstl.h:117
List(size_type _N, const _TYPE &_V=_TYPE())
[AI] Constructs a List with a specified number of elements and initial value.
Definition: mxstl.h:100
[AI] Custom wrapper for std::map with consistent allocator and customizable comparator.
Definition: mxstl.h:130
allocator< _TYPE > _A
[AI] Allocator type [AI]
Definition: mxstl.h:133
Map(const _Pr &_Pred=_Pr())
[AI] Constructs an empty Map with an optional predicate.
Definition: mxstl.h:139
friend void swap(_Myt &_X, _Myt &_Y)
[AI] Friend swap for Map.
Definition: mxstl.h:157
Map< _K, _TYPE, _Pr > _Myt
[AI] Self type [AI]
Definition: mxstl.h:132
void swap(_Myt &_X)
[AI] Swaps with another Map.
Definition: mxstl.h:147
[AI] Custom multimap supporting multiple values per key with custom allocator and comparator.
Definition: mxstl.h:170
void swap(_Myt &_X)
[AI] Swaps with another Multimap.
Definition: mxstl.h:186
allocator< _TYPE > _A
[AI] Allocator type [AI]
Definition: mxstl.h:173
Multimap(const _Pr &_Pred=_Pr())
[AI] Constructs an empty Multimap with optional predicate.
Definition: mxstl.h:179
Multimap< _K, _TYPE, _Pr > _Myt
[AI] Self type [AI]
Definition: mxstl.h:172
friend void swap(_Myt &_X, _Myt &_Y)
[AI] Friend swap for Multimap.
Definition: mxstl.h:196
[AI] Multiset wrapper for storing ordered collections of non-unique elements with a custom allocator.
Definition: mxstl.h:248
Multiset(const _Pr &_Pred=_Pr())
[AI] Constructs an empty Multiset with an optional predicate.
Definition: mxstl.h:257
allocator< _K > _A
[AI] Allocator type [AI]
Definition: mxstl.h:251
Multiset< _K, _Pr > _Myt
[AI] Self type [AI]
Definition: mxstl.h:250
void swap(_Myt &_X)
[AI] Swaps with another Multiset.
Definition: mxstl.h:265
friend void swap(_Myt &_X, _Myt &_Y)
[AI] Friend swap for Multiset.
Definition: mxstl.h:275
[AI] Customized priority queue for use with game-specific containers and allocators.
Definition: mxstl.h:327
_C::allocator_type _A
[AI] Allocator type [AI]
Definition: mxstl.h:330
_C::value_type _TYPE
[AI] Element type [AI]
Definition: mxstl.h:329
Priority_queue(const _Pr &_X=_Pr(), const _C::allocator_type &_Al=_C::allocator_type())
[AI] Constructs an empty Priority_queue with optional comparator and allocator.
Definition: mxstl.h:338
_C::allocator_type allocator_type
[AI] Allocator type (synonym) [AI]
Definition: mxstl.h:331
[AI] Customized queue for compatibility with the engine's allocator requirements.
Definition: mxstl.h:349
[AI] Set wrapper utilizing a custom allocator and comparator.
Definition: mxstl.h:209
Set< _K, _Pr > _Myt
[AI] Self type [AI]
Definition: mxstl.h:211
allocator< _K > _A
[AI] Allocator type [AI]
Definition: mxstl.h:212
void swap(_Myt &_X)
[AI] Swaps with another Set.
Definition: mxstl.h:225
Set(const _Pr &_Pred=_Pr())
[AI] Constructs an empty Set with an optional predicate.
Definition: mxstl.h:218
friend void swap(_Myt &_X, _Myt &_Y)
[AI] Friend swap for Set.
Definition: mxstl.h:235
[AI] Customized stack for compatibility with the engine's allocator and usage patterns.
Definition: mxstl.h:358
[AI] Custom vector supporting allocator and custom swap semantics.
Definition: mxstl.h:288
void swap(_Myt &_X)
[AI] Swaps the content with another Vector.
Definition: mxstl.h:304
Vector< _TYPE > _Myt
[AI] Self type [AI]
Definition: mxstl.h:290
allocator< _TYPE > _A
[AI] Allocator type [AI]
Definition: mxstl.h:291
friend void swap(_Myt &_X, _Myt &_Y)
[AI] Friend swap for Vector.
Definition: mxstl.h:314
Vector(const _A &_Al=_A())
[AI] Constructs an empty Vector with an optional allocator.
Definition: mxstl.h:297
#define priority_queue
[AI] Macro alias for Priority_queue<C, Pr>, replacing std::priority_queue.
Definition: mxstl.h:416
#define deque
[AI] Macro alias for Deque<T>, replacing std::deque<T>.
Definition: mxstl.h:409
#define multimap
[AI] Macro alias for Multimap<K, T, Pr>, replacing std::multimap<T>.
Definition: mxstl.h:412
#define queue
[AI] Macro alias for Queue<C>, replacing std::queue.
Definition: mxstl.h:417
#define stack
[AI] Macro alias for Stack<C>, replacing std::stack.
Definition: mxstl.h:418
#define multiset
[AI] Macro alias for Multiset<K, Pr>, replacing std::multiset<K>.
Definition: mxstl.h:414
#define set
[AI] Macro alias for Set<K, Pr>, replacing std::set<K>.
Definition: mxstl.h:413
#define vector
[AI] Macro alias for Vector<T>, replacing std::vector<T>.
Definition: mxstl.h:415
#define map
[AI] Macro alias for Map<K, T, Pr>, replacing std::map<T>.
Definition: mxstl.h:411
#define list
[AI] Macro alias for List<T>, replacing std::list<T>.
Definition: mxstl.h:410