1 #ifndef MiscLib__NOSHRINKVECTOR_HEADER__
2 #define MiscLib__NOSHRINKVECTOR_HEADER__
16 template<
class T,
class AllocatorT = MiscLib::AlignedAllocator< T > >
18 :
protected AllocatorT
42 m_begin = AllocatorT::allocate(
s);
48 AllocatorT::construct(m_begin + i,
v);
54 m_begin = AllocatorT::allocate(
s);
59 AllocatorT::construct(m_begin + i,
v);
73 m_begin = AllocatorT::allocate(
s);
78 AllocatorT::construct(m_begin + i,
v.m_begin[i]);
82 template<
class OtherAllocatorT >
93 m_begin = AllocatorT::allocate(
s);
98 AllocatorT::construct(m_begin + i,
v.m_begin[i]);
108 AllocatorT::destroy(m_begin + i);
110 AllocatorT::deallocate(m_begin,
capacity());
130 AllocatorT::destroy(m_begin + i);
132 AllocatorT::deallocate(m_begin,
capacity());
134 m_begin = AllocatorT::allocate(
s);
139 AllocatorT::construct(m_begin + i,
v.m_begin[i]);
144 template<
class OtherAllocatorT >
157 AllocatorT::destroy(m_begin + i);
159 AllocatorT::deallocate(m_begin,
capacity());
161 m_begin = AllocatorT::allocate(
s);
166 AllocatorT::construct(m_begin + i,
v.m_begin[i]);
175 AllocatorT::destroy(m_begin + i);
186 AllocatorT::destroy(m_begin + i);
188 AllocatorT::deallocate(m_begin,
capacity());
190 m_end = m_begin = m_capacity = NULL;
202 T* newBegin = AllocatorT::allocate(
s);
207 AllocatorT::construct(newBegin + i, m_begin[i]);
208 AllocatorT::destroy(m_begin + i);
210 AllocatorT::deallocate(m_begin,
capacity());
212 m_end = newBegin + olds;
214 m_capacity = m_begin +
s;
220 return m_end - m_begin;
225 return m_capacity - m_begin;
239 AllocatorT::destroy(m_begin + i);
243 AllocatorT::construct(m_begin + i,
v);
248 T* newBegin = AllocatorT::allocate(2 *
s);
253 AllocatorT::construct(newBegin + i, m_begin[i]);
254 AllocatorT::destroy(m_begin + i);
256 AllocatorT::deallocate(m_begin,
capacity());
259 AllocatorT::construct(newBegin + i,
v);
266 AllocatorT::construct(newBegin + i,
v);
269 m_end = newBegin +
s;
271 m_capacity = m_begin + 2 *
s;
284 operator const T* ()
const
301 if (m_end >= m_capacity)
309 T* newBegin = AllocatorT::allocate(
s);
314 AllocatorT::construct(newBegin + i, m_begin[i]);
315 AllocatorT::destroy(m_begin + i);
317 AllocatorT::deallocate(m_begin,
capacity());
319 m_end = newBegin + olds;
321 m_capacity = m_begin +
s;
323 AllocatorT::construct(m_end,
v);
330 if (m_end >= m_capacity)
338 T* newBegin = AllocatorT::allocate(
s);
343 AllocatorT::construct(newBegin + i, m_begin[i]);
344 AllocatorT::destroy(m_begin + i);
346 AllocatorT::deallocate(m_begin,
capacity());
348 m_end = newBegin + olds;
350 m_capacity = m_begin +
s;
351 where = m_begin + whereIdx;
353 if (
size() > whereIdx)
355 AllocatorT::construct(m_end, m_begin[
size() - 1]);
358 m_begin[i] = m_begin[i - 1];
364 AllocatorT::construct(where,
v);
373 m_begin[i] = m_begin[i + 1];
376 AllocatorT::destroy(m_end);
382 AllocatorT::destroy(m_end);
407 return std::reverse_iterator< T* >(m_end);
412 return std::reverse_iterator< const T* >(m_end);
417 return std::reverse_iterator< T* >(m_begin);
422 return std::reverse_iterator< const T* >(m_begin);