1#ifndef MiscLib__NOSHRINKVECTOR_HEADER__
2#define MiscLib__NOSHRINKVECTOR_HEADER__
16 template <
class T,
class AllocatorT = MiscLib::AlignedAllocator<T>>
41 m_begin = AllocatorT::allocate(s);
47 AllocatorT::construct(m_begin + i, v);
53 m_begin = AllocatorT::allocate(s);
58 AllocatorT::construct(m_begin + i, v);
72 m_begin = AllocatorT::allocate(s);
77 AllocatorT::construct(m_begin + i, v.m_begin[i]);
81 template <
class OtherAllocatorT>
92 m_begin = AllocatorT::allocate(s);
97 AllocatorT::construct(m_begin + i, v.m_begin[i]);
107 AllocatorT::destroy(m_begin + i);
109 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>
158 AllocatorT::destroy(m_begin + i);
160 AllocatorT::deallocate(m_begin,
capacity());
162 m_begin = AllocatorT::allocate(s);
167 AllocatorT::construct(m_begin + i, v.m_begin[i]);
177 AllocatorT::destroy(m_begin + i);
189 AllocatorT::destroy(m_begin + i);
191 AllocatorT::deallocate(m_begin,
capacity());
193 m_end = m_begin = m_capacity = NULL;
206 T* newBegin = AllocatorT::allocate(s);
211 AllocatorT::construct(newBegin + i, m_begin[i]);
212 AllocatorT::destroy(m_begin + i);
214 AllocatorT::deallocate(m_begin,
capacity());
216 m_end = newBegin + olds;
218 m_capacity = m_begin + s;
225 return m_end - m_begin;
231 return m_capacity - m_begin;
246 AllocatorT::destroy(m_begin + i);
250 AllocatorT::construct(m_begin + i, v);
255 T* newBegin = AllocatorT::allocate(2 * s);
260 AllocatorT::construct(newBegin + i, m_begin[i]);
261 AllocatorT::destroy(m_begin + i);
263 AllocatorT::deallocate(m_begin,
capacity());
266 AllocatorT::construct(newBegin + i, v);
273 AllocatorT::construct(newBegin + i, v);
276 m_end = newBegin + s;
278 m_capacity = m_begin + 2 * s;
292 operator const T*()
const
312 if (m_end >= m_capacity)
320 T* newBegin = AllocatorT::allocate(s);
325 AllocatorT::construct(newBegin + i, m_begin[i]);
326 AllocatorT::destroy(m_begin + i);
328 AllocatorT::deallocate(m_begin,
capacity());
330 m_end = newBegin + olds;
332 m_capacity = m_begin + s;
334 AllocatorT::construct(m_end, v);
342 if (m_end >= m_capacity)
350 T* newBegin = AllocatorT::allocate(s);
355 AllocatorT::construct(newBegin + i, m_begin[i]);
356 AllocatorT::destroy(m_begin + i);
358 AllocatorT::deallocate(m_begin,
capacity());
360 m_end = newBegin + olds;
362 m_capacity = m_begin + s;
363 where = m_begin + whereIdx;
365 if (
size() > whereIdx)
367 AllocatorT::construct(m_end, m_begin[
size() - 1]);
370 m_begin[i] = m_begin[i - 1];
376 AllocatorT::construct(where, v);
386 m_begin[i] = m_begin[i + 1];
389 AllocatorT::destroy(m_end);
396 AllocatorT::destroy(m_end);
426 return std::reverse_iterator<T*>(m_end);
432 return std::reverse_iterator<const T*>(m_end);
438 return std::reverse_iterator<T*>(m_begin);
444 return std::reverse_iterator<const T*>(m_begin);
const_reverse_iterator rend() const
void resize(size_type s, const value_type &v)
std::reverse_iterator< const T * > const_reverse_iterator
NoShrinkVector(const NoShrinkVector< T, OtherAllocatorT > &v)
NoShrinkVector< T > & operator=(const NoShrinkVector< T, AllocatorT > &v)
NoShrinkVector(size_type s, const T &v)
std::reverse_iterator< T * > reverse_iterator
NoShrinkVector(const NoShrinkVector< T, AllocatorT > &v)
NoShrinkVector< T > & operator=(const NoShrinkVector< T, OtherAllocatorT > &v)
void push_back(const T &v)
void reserve(size_type s)
reverse_iterator rbegin()
size_type capacity() const
const T & at(size_type i) const
NoShrinkVector(size_type s)
const_reverse_iterator rbegin() const
const T & const_reference
void insert(T *where, const T &v)