// // begin license header // // This file is part of Pixy CMUcam5 or "Pixy" for short // // All Pixy source code is provided under the terms of the // GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html). // Those wishing to use Pixy source code, software and/or // technologies under different licensing terms should contact us at // cmucam@cs.cmu.edu. Such licensing terms are available for // all portions of the Pixy codebase presented here. // // end license header // #ifndef SIMPLEVECTOR_H #define SIMPLEVECTOR_H #include #define SPARE_CAPACITY 16 template class SimpleVector { public: SimpleVector(int initSize = 0) : m_size(0), m_capacity(initSize + SPARE_CAPACITY) { m_objects = new Object[m_capacity]; } ~SimpleVector() { delete [] m_objects; } int resize(int newCapacity) { if(newCapacity < m_size) return 0; Object *oldArray = m_objects; m_objects = new (std::nothrow) Object[newCapacity]; if (m_objects==NULL) { m_objects = oldArray; return -1; } for(int k = 0; k