22 #ifndef ULTIMA_STD_CONTAINERS_H 23 #define ULTIMA_STD_CONTAINERS_H 25 #include "common/algorithm.h" 26 #include "common/array.h" 27 #include "common/hashmap.h" 28 #include "common/hash-str.h" 29 #include "common/list.h" 30 #include "common/queue.h" 31 #include "common/stack.h" 32 #include "common/util.h" 48 T &operator*() {
return (*_owner)[_index]; }
56 return _owner == rhs._owner && _index == rhs._index;
59 return !operator==(rhs);
73 const T operator*()
const {
74 return (*_owner)[_index];
83 return _owner == rhs._owner && _index == rhs._index;
86 return !operator==(rhs);
91 typedef const T const_reference;
114 T at(
size_t index)
const {
115 return (*
this)[index];
122 bool operator()(
const T &a,
const T &b)
const {
128 Comparitor _comparitor;
134 iterator
end() {
return _items.
end(); }
135 const_iterator
begin()
const {
return _items.
begin(); }
136 const_iterator
end()
const {
return _items.
end(); }
156 void insert(iterator first, iterator last) {
157 for (; first != last; ++first)
173 iterator it =
begin();
174 for (; it !=
end() && *it != item; ++it) {}
177 const_iterator
find(
const T item)
const {
178 const_iterator it =
begin();
179 for (; it !=
end() && *it != item; ++it) {
190 it != this->
end(); ++it, --index) {
195 error(
"Invalid index");
209 T operator*()
const {
return *_it; }
233 template <
class _Ty,
class _Container,
class _Pr>
240 priority_queue(
const _Pr &_Pred,
const _Container &_Cont) : c(_Cont), comp(_Pred) {
241 make_heap(c.begin(), c.end(), comp);
244 template <
class _InIt>
245 priority_queue(_InIt _First, _InIt _Last,
const _Pr &_Pred,
const _Container &_Cont) : c(_Cont), comp(_Pred) {
246 c.insert(c.end(), _First, _Last);
247 make_heap(c.begin(), c.end(), comp);
250 template <
class _InIt>
251 priority_queue(_InIt _First, _InIt _Last) : c(_First, _Last), comp() {
252 make_heap(c.begin(), c.end(), comp);
255 template <
class _InIt>
256 priority_queue(_InIt _First, _InIt _Last,
const _Pr &_Pred) : c(_First, _Last), comp(_Pred) {
257 make_heap(c.begin(), c.end(), comp);
264 size_t size()
const {
268 typename _Container::const_reference top()
const {
272 void push(
const typename _Container::value_type &_Val) {
281 void swap(priority_queue &_Right) {
283 SWAP(comp, _Right.comp);
Definition: containers.h:120
Definition: containers.h:40
Definition: containers.h:186
void clear()
Definition: containers.h:141
void clear()
Definition: array.h:320
iterator end()
Definition: array.h:379
iterator begin()
Definition: array.h:374
In find(In first, In last, const T &v)
Definition: algorithm.h:225
T & operator[](size_type idx)
Definition: array.h:273
T * iterator
Definition: array.h:54
void SWAP(T &a, T &b)
Definition: util.h:82
void insert(T val)
Definition: containers.h:148
Definition: detection.h:27
bool empty() const
Definition: array.h:351
void push_back(const T &element)
Definition: array.h:180
iterator find(const T item)
Definition: containers.h:172
const T * const_iterator
Definition: array.h:55
Definition: containers.h:234
void insert(iterator first, iterator last)
Definition: containers.h:156
size_type size() const
Definition: array.h:315
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: containers.h:200
Definition: containers.h:202
T remove_at(size_type idx)
Definition: array.h:260
Definition: list_intern.h:51
void sort(T first, T last, StrictWeakOrdering comp)
Definition: algorithm.h:349
Definition: containers.h:38
Definition: algorithm.h:37
void swap(set< T > &arr)
Definition: containers.h:165
Definition: containers.h:63