1 #ifndef MiscLib__VECTOR_HEADER__
2 #define MiscLib__VECTOR_HEADER__
18 template <
class T,
class AllocatorT = MiscLib::AlignedAllocator<T>>
43 m_begin = AllocatorT::allocate(
s);
49 AllocatorT::construct(m_begin + i,
v);
55 m_begin = AllocatorT::allocate(
s);
60 AllocatorT::construct(m_begin + i,
v);
74 m_begin = AllocatorT::allocate(
s);
79 AllocatorT::construct(m_begin + i,
v.m_begin[i]);
83 template <
class OtherAllocatorT>
94 m_begin = AllocatorT::allocate(
s);
99 AllocatorT::construct(m_begin + i,
v.m_begin[i]);
109 AllocatorT::destroy(m_begin + i);
111 AllocatorT::deallocate(m_begin,
capacity());
132 AllocatorT::destroy(m_begin + i);
134 AllocatorT::deallocate(m_begin,
capacity());
136 m_begin = AllocatorT::allocate(
s);
141 AllocatorT::construct(m_begin + i,
v.m_begin[i]);
146 template <
class OtherAllocatorT>
160 AllocatorT::destroy(m_begin + i);
162 AllocatorT::deallocate(m_begin,
capacity());
164 m_begin = AllocatorT::allocate(
s);
169 AllocatorT::construct(m_begin + i,
v.m_begin[i]);
181 AllocatorT::destroy(m_begin + i);
183 AllocatorT::deallocate(m_begin,
capacity());
185 m_end = m_begin = m_capacity = NULL;
198 T* newBegin = AllocatorT::allocate(
s);
203 AllocatorT::construct(newBegin + i, m_begin[i]);
204 AllocatorT::destroy(m_begin + i);
206 AllocatorT::deallocate(m_begin,
capacity());
208 m_end = newBegin + olds;
210 m_capacity = m_begin +
s;
217 return m_end - m_begin;
223 return m_capacity - m_begin;
238 T* newBegin = AllocatorT::allocate(
s);
240 for (
size_type i = 0; i < copyRange; ++i)
242 AllocatorT::construct(newBegin + i, m_begin[i]);
243 AllocatorT::destroy(m_begin + i);
247 AllocatorT::destroy(m_begin + i);
251 AllocatorT::construct(newBegin + i,
v);
253 AllocatorT::deallocate(m_begin,
capacity());
254 m_end = newBegin +
s;
256 m_capacity = m_begin +
s;
261 AllocatorT::construct(m_begin + i,
v);
265 AllocatorT::destroy(m_begin + i);
271 T* newBegin = AllocatorT::allocate(newCapacity);
276 AllocatorT::construct(newBegin + i, m_begin[i]);
277 AllocatorT::destroy(m_begin + i);
279 AllocatorT::deallocate(m_begin,
capacity());
282 AllocatorT::construct(newBegin + i,
v);
289 AllocatorT::construct(newBegin + i,
v);
292 m_end = newBegin +
s;
294 m_capacity = m_begin + newCapacity;
308 operator const T*()
const
356 if (m_end >= m_capacity)
364 T* newBegin = AllocatorT::allocate(
s);
369 AllocatorT::construct(newBegin + i, m_begin[i]);
370 AllocatorT::destroy(m_begin + i);
372 AllocatorT::deallocate(m_begin,
capacity());
374 m_end = newBegin + olds;
376 m_capacity = m_begin +
s;
378 AllocatorT::construct(m_end,
v);
386 if (m_end >= m_capacity)
394 T* newBegin = AllocatorT::allocate(
s);
399 AllocatorT::construct(newBegin + i, m_begin[i]);
400 AllocatorT::destroy(m_begin + i);
402 AllocatorT::deallocate(m_begin,
capacity());
404 m_end = newBegin + olds;
406 m_capacity = m_begin +
s;
407 where = m_begin + whereIdx;
409 if (
size() > whereIdx)
411 AllocatorT::construct(m_end, m_begin[
size() - 1]);
414 m_begin[i] = m_begin[i - 1];
420 AllocatorT::construct(where,
v);
430 m_begin[i] = m_begin[i + 1];
433 AllocatorT::destroy(m_end);
437 T* newBegin = AllocatorT::allocate(
size());
440 AllocatorT::construct(newBegin + i, m_begin[i]);
441 AllocatorT::destroy(m_begin + i);
443 AllocatorT::deallocate(m_begin,
capacity());
444 m_end = newBegin +
s;
446 m_capacity = m_begin +
s;
454 AllocatorT::destroy(m_end);
458 T* newBegin = AllocatorT::allocate(
size());
461 AllocatorT::construct(newBegin + i, m_begin[i]);
462 AllocatorT::destroy(m_begin + i);
464 AllocatorT::deallocate(m_begin,
capacity());
465 m_end = newBegin +
s;
467 m_capacity = m_begin +
s;
498 return std::reverse_iterator<T*>(m_end);
504 return std::reverse_iterator<const T*>(m_end);
510 return std::reverse_iterator<T*>(m_begin);
516 return std::reverse_iterator<const T*>(m_begin);