Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

232 lines
6.3 KiB

  1. // stl.h supplemental header
  2. #ifndef _STL_H_
  3. #define _STL_H_
  4. #include <algorithm>
  5. #include <deque>
  6. #include <functional>
  7. #include <iterator>
  8. #include <list>
  9. #include <map>
  10. #include <memory>
  11. #include <numeric>
  12. #include <queue>
  13. #include <set>
  14. #include <stack>
  15. #include <utility>
  16. #include <vector>
  17. using namespace std;
  18. // TEMPLATE CLASS Deque
  19. template<class _Ty>
  20. class Deque : public deque<_Ty, allocator<_Ty> > {
  21. public:
  22. typedef Deque<_Ty> _Myt;
  23. typedef allocator<_Ty> _A;
  24. explicit Deque()
  25. : deque<_Ty, _A>() {}
  26. explicit Deque(size_type _N, const _Ty& _V = _Ty())
  27. : deque<_Ty, _A>(_N, _V) {}
  28. typedef const_iterator _It;
  29. Deque(_It _F, _It _L)
  30. : deque<_Ty, _A>(_F, _L) {}
  31. void swap(_Myt& _X)
  32. {deque<_Ty, _A>::swap((deque<_Ty, _A>&)_X); }
  33. friend void swap(_Myt& _X, _Myt& _Y)
  34. {_X.swap(_Y); }
  35. };
  36. // TEMPLATE CLASS List
  37. template<class _Ty>
  38. class List : public list<_Ty, allocator<_Ty> > {
  39. public:
  40. typedef List<_Ty> _Myt;
  41. typedef allocator<_Ty> _A;
  42. explicit List()
  43. : list<_Ty, _A>() {}
  44. explicit List(size_type _N, const _Ty& _V = _Ty())
  45. : list<_Ty, _A>(_N, _V) {}
  46. typedef const_iterator _It;
  47. List(_It _F, _It _L)
  48. : list<_Ty, _A>(_F, _L) {}
  49. void swap(_Myt& _X)
  50. {list<_Ty, _A>::swap((list<_Ty, _A>&)_X); }
  51. friend void swap(_Myt& _X, _Myt& _Y)
  52. {_X.swap(_Y); }
  53. };
  54. // TEMPLATE CLASS Map
  55. template<class _K, class _Ty, class _Pr = less<_K> >
  56. class Map : public map<_K, _Ty, _Pr, allocator<_Ty> > {
  57. public:
  58. typedef Map<_K, _Ty, _Pr> _Myt;
  59. typedef allocator<_Ty> _A;
  60. explicit Map(const _Pr& _Pred = _Pr())
  61. : map<_K, _Ty, _Pr, _A>(_Pred) {}
  62. typedef const_iterator _It;
  63. Map(_It _F, _It _L, const _Pr& _Pred = _Pr())
  64. : map<_K, _Ty, _Pr, _A>(_F, _L, _Pred) {}
  65. void swap(_Myt& _X)
  66. {map<_K, _Ty, _Pr, _A>::
  67. swap((map<_K, _Ty, _Pr, _A>&)_X); }
  68. friend void swap(_Myt& _X, _Myt& _Y)
  69. {_X.swap(_Y); }
  70. };
  71. // TEMPLATE CLASS Multimap
  72. template<class _K, class _Ty, class _Pr = less<_K> >
  73. class Multimap
  74. : public multimap<_K, _Ty, _Pr, allocator<_Ty> > {
  75. public:
  76. typedef Multimap<_K, _Ty, _Pr> _Myt;
  77. typedef allocator<_Ty> _A;
  78. explicit Multimap(const _Pr& _Pred = _Pr())
  79. : multimap<_K, _Ty, _Pr, _A>(_Pred) {}
  80. typedef const_iterator _It;
  81. Multimap(_It _F, _It _L, const _Pr& _Pred = _Pr())
  82. : multimap<_K, _Ty, _Pr, _A>(_F, _L, _Pred) {}
  83. void swap(_Myt& _X)
  84. {multimap<_K, _Ty, _Pr, _A>::
  85. swap((multimap<_K, _Ty, _Pr, _A>&)_X); }
  86. friend void swap(_Myt& _X, _Myt& _Y)
  87. {_X.swap(_Y); }
  88. };
  89. // TEMPLATE CLASS Set
  90. template<class _K, class _Pr = less<_K> >
  91. class Set : public set<_K, _Pr, allocator<_K> > {
  92. public:
  93. typedef Set<_K, _Pr> _Myt;
  94. typedef allocator<_K> _A;
  95. explicit Set(const _Pr& _Pred = _Pr())
  96. : set<_K, _Pr, _A>(_Pred) {}
  97. typedef const_iterator _It;
  98. Set(_It _F, _It _L, const _Pr& _Pred = _Pr())
  99. : set<_K, _Pr, _A>(_F, _L, _Pred) {}
  100. void swap(_Myt& _X)
  101. {set<_K, _Pr, _A>::swap((set<_K, _Pr, _A>&)_X); }
  102. friend void swap(_Myt& _X, _Myt& _Y)
  103. {_X.swap(_Y); }
  104. };
  105. // TEMPLATE CLASS Multiset
  106. template<class _K, class _Pr = less<_K> >
  107. class Multiset : public multiset<_K, _Pr, allocator<_K> > {
  108. public:
  109. typedef Multiset<_K, _Pr> _Myt;
  110. typedef allocator<_K> _A;
  111. explicit Multiset(const _Pr& _Pred = _Pr())
  112. : multiset<_K, _Pr, _A>(_Pred) {}
  113. typedef const_iterator _It;
  114. Multiset(_It _F, _It _L, const _Pr& _Pred = _Pr())
  115. : multiset<_K, _Pr, _A>(_F, _L, _Pred) {}
  116. void swap(_Myt& _X)
  117. {multiset<_K, _Pr, _A>::
  118. swap((multiset<_K, _Pr, _A>&)_X); }
  119. friend void swap(_Myt& _X, _Myt& _Y)
  120. {_X.swap(_Y); }
  121. };
  122. // TEMPLATE CLASS Vector
  123. template<class _Ty>
  124. class Vector : public vector<_Ty, allocator<_Ty> > {
  125. public:
  126. typedef Vector<_Ty> _Myt;
  127. typedef allocator<_Ty> _A;
  128. explicit Vector()
  129. : vector<_Ty, _A>(_Al) {}
  130. explicit Vector(size_type _N, const _Ty& _V = _Ty())
  131. : vector<_Ty, _A>(_N, _V) {}
  132. typedef const_iterator _It;
  133. Vector(_It _F, _It _L)
  134. : vector<_Ty, _A>(_F, _L) {}
  135. void swap(_Myt& _X)
  136. {vector<_Ty, _A>::swap((vector<_Ty, _A>&)_X); }
  137. friend void swap(_Myt& _X, _Myt& _Y)
  138. {_X.swap(_Y); }
  139. };
  140. // CLASS bit_vector
  141. class bit_vector : public vector<_Bool, _Bool_allocator> {
  142. public:
  143. typedef _Bool _Ty;
  144. typedef _Bool_allocator _A;
  145. typedef bit_vector _Myt;
  146. explicit bit_vector()
  147. : vector<_Bool, _Bool_allocator>() {}
  148. explicit bit_vector(size_type _N, const _Ty& _V = _Ty())
  149. : vector<_Bool, _Bool_allocator>(_N, _V) {}
  150. typedef const_iterator _It;
  151. bit_vector(_It _F, _It _L)
  152. : vector<_Bool, _Bool_allocator>(_F, _L) {}
  153. void swap(_Myt& _X)
  154. {vector<_Bool, _Bool_allocator>::
  155. swap((vector<_Bool, _Bool_allocator>&)_X); }
  156. friend void swap(_Myt& _X, _Myt& _Y)
  157. {_X.swap(_Y); }
  158. };
  159. // TEMPLATE CLASS priority_queue
  160. template<class _C = vector<_Ty>,
  161. class _Pr = less<_C::value_type> >
  162. class Priority_queue
  163. : public priority_queue<_C::value_type, _C, _Pr,
  164. allocator<_C::value_type> > {
  165. public:
  166. typedef _C::value_type _Ty;
  167. typedef allocator<_C::value_type> _A;
  168. explicit Priority_queue(const _Pr& _X = _Pr())
  169. : priority_queue<_Ty, _C, _Pr, _A>(_X) {}
  170. typedef const value_type *_It;
  171. Priority_queue(_It _F, _It _L, const _Pr& _X = _Pr())
  172. : priority_queue<_Ty, _C, _Pr, _A>(_F, _L, _X) {}
  173. };
  174. // TEMPLATE CLASS queue
  175. template<class _C = deque<_Ty> >
  176. class Queue
  177. : public queue<_C::value_type, _C,
  178. allocator<_C::value_type> > {
  179. };
  180. // TEMPLATE CLASS stack
  181. template<class _C = deque<_Ty> >
  182. class Stack
  183. : public stack<_C::value_type, _C,
  184. allocator<_C::value_type> > {
  185. };
  186. // MACRO DEFINITIONS
  187. #define deque Deque
  188. #define list List
  189. #define map Map
  190. #define multimap Multimap
  191. #define set Set
  192. #define multiset Multiset
  193. #define vector Vector
  194. #define priority_queue Priority_queue
  195. #define queue Queue
  196. #define stack Stack
  197. #endif /* _STL_H_ */
  198. /*
  199. * Copyright (c) 1996 by P.J. Plauger. ALL RIGHTS RESERVED.
  200. * Consult your license regarding permissions and restrictions.
  201. */
  202. /*
  203. * This file is derived from software bearing the following
  204. * restrictions:
  205. *
  206. * Copyright (c) 1994
  207. * Hewlett-Packard Company
  208. *
  209. * Permission to use, copy, modify, distribute and sell this
  210. * software and its documentation for any purpose is hereby
  211. * granted without fee, provided that the above copyright notice
  212. * appear in all copies and that both that copyright notice and
  213. * this permission notice appear in supporting documentation.
  214. * Hewlett-Packard Company makes no representations about the
  215. * suitability of this software for any purpose. It is provided
  216. * "as is" without express or implied warranty.
  217. */