// vector standard header #pragma once #ifndef _TESTHPP_ #define _TESTHPP_ template class my_vector { private: _Type *m_Front; _Type *m_Tail; _Type *m_End; int m_grow_size; public: my_vector (int growsize=1) { m_Front = m_Tail = m_End; m_grow_size = growsize; } ~my_vector (void) { delete m_Front; m_Front = m_Tail = m_End; } _Type& at (int index) { assert (index>=0); assert (index < (m_Tail - m_Front)); return m_Front[index]; } const _Type& at (int index) const { assert (index>=0); assert (index < (m_Tail - m_Front)); return m_Front[index]; } _Type& operator[] (int index) { assert (index>=0); assert (index < (m_Tail - m_Front)); return m_Front[index]; } const _Type& operator[] (int index) const { assert (index>=0); assert (index < (m_Tail - m_Front)); return m_Front[index]; } void clear (void) { erase (0,size); } bool empty (void) { return m_Front == m_Tail; } void erase (int index) { int i,count; assert (index>=0); assert (index < (m_Tail - m_Front)); count = m_Tail - m_Start; for (i=index;i~_Type (); m_Tail--; } void push_back (const _Type& element) { if (m_Tail == m_End) { reserve ((m_Tail - m_Front)+m_grow_size); } m_Tail++; *m_Tail = element; } void reserve (int amount) { if (amount > (m_End-m_Front)) { _Type *temp,*cur; int i,count; temp = new _Type[amount]; count = m_Tail - m_Front; cur = temp; for (i=0;i