1 #ifndef MiscLib__VECTOR_HEADER__
2 #define MiscLib__VECTOR_HEADER__
18 template<
class T,
class AllocatorT = MiscLib::AlignedAllocator< T > >
20 :
protected AllocatorT
44 m_begin = AllocatorT::allocate(
s);
50 AllocatorT::construct(m_begin + i,
v);
56 m_begin = AllocatorT::allocate(
s);
61 AllocatorT::construct(m_begin + i,
v);
76 m_begin = AllocatorT::allocate(
s);
81 AllocatorT::construct(m_begin + i,
v.m_begin[i]);
85 template<
class OtherAllocatorT >
96 m_begin = AllocatorT::allocate(
s);
101 AllocatorT::construct(m_begin + i,
v.m_begin[i]);
111 AllocatorT::destroy(m_begin + i);
113 AllocatorT::deallocate(m_begin,
capacity());
133 AllocatorT::destroy(m_begin + i);
135 AllocatorT::deallocate(m_begin,
capacity());
137 m_begin = AllocatorT::allocate(
s);
142 AllocatorT::construct(m_begin + i,
v.m_begin[i]);
147 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]);
180 AllocatorT::destroy(m_begin + i);
182 AllocatorT::deallocate(m_begin,
capacity());
184 m_end = m_begin = m_capacity = NULL;
196 T* newBegin = AllocatorT::allocate(
s);
201 AllocatorT::construct(newBegin + i, m_begin[i]);
202 AllocatorT::destroy(m_begin + i);
204 AllocatorT::deallocate(m_begin,
capacity());
206 m_end = newBegin + olds;
208 m_capacity = m_begin +
s;
214 return m_end - m_begin;
219 return m_capacity - m_begin;
233 T* newBegin = AllocatorT::allocate(
s);
235 for (
size_type i = 0; i < copyRange; ++i)
237 AllocatorT::construct(newBegin + i, m_begin[i]);
238 AllocatorT::destroy(m_begin + i);
242 AllocatorT::destroy(m_begin + i);
246 AllocatorT::construct(newBegin + i,
v);
248 AllocatorT::deallocate(m_begin,
capacity());
249 m_end = newBegin +
s;
251 m_capacity = m_begin +
s;
256 AllocatorT::construct(m_begin + i,
v);
260 AllocatorT::destroy(m_begin + i);
267 T* newBegin = AllocatorT::allocate(newCapacity);
272 AllocatorT::construct(newBegin + i, m_begin[i]);
273 AllocatorT::destroy(m_begin + i);
275 AllocatorT::deallocate(m_begin,
capacity());
278 AllocatorT::construct(newBegin + i,
v);
285 AllocatorT::construct(newBegin + i,
v);
288 m_end = newBegin +
s;
290 m_capacity = m_begin + newCapacity;
303 operator const T* ()
const
348 if (m_end >= m_capacity)
356 T* newBegin = AllocatorT::allocate(
s);
361 AllocatorT::construct(newBegin + i, m_begin[i]);
362 AllocatorT::destroy(m_begin + i);
364 AllocatorT::deallocate(m_begin,
capacity());
366 m_end = newBegin + olds;
368 m_capacity = m_begin +
s;
370 AllocatorT::construct(m_end,
v);
377 if (m_end >= m_capacity)
385 T* newBegin = AllocatorT::allocate(
s);
390 AllocatorT::construct(newBegin + i, m_begin[i]);
391 AllocatorT::destroy(m_begin + i);
393 AllocatorT::deallocate(m_begin,
capacity());
395 m_end = newBegin + olds;
397 m_capacity = m_begin +
s;
398 where = m_begin + whereIdx;
400 if (
size() > whereIdx)
402 AllocatorT::construct(m_end, m_begin[
size() - 1]);
405 m_begin[i] = m_begin[i - 1];
411 AllocatorT::construct(where,
v);
420 m_begin[i] = m_begin[i + 1];
423 AllocatorT::destroy(m_end);
427 T* newBegin = AllocatorT::allocate(
size());
430 AllocatorT::construct(newBegin + i, m_begin[i]);
431 AllocatorT::destroy(m_begin + i);
433 AllocatorT::deallocate(m_begin,
capacity());
434 m_end = newBegin +
s;
436 m_capacity = m_begin +
s;
443 AllocatorT::destroy(m_end);
447 T* newBegin = AllocatorT::allocate(
size());
450 AllocatorT::construct(newBegin + i, m_begin[i]);
451 AllocatorT::destroy(m_begin + i);
453 AllocatorT::deallocate(m_begin,
capacity());
454 m_end = newBegin +
s;
456 m_capacity = m_begin +
s;
482 return std::reverse_iterator< T* >(m_end);
487 return std::reverse_iterator< const T* >(m_end);
492 return std::reverse_iterator< T* >(m_begin);
497 return std::reverse_iterator< const T* >(m_begin);