22 #ifndef DOXYGEN_NOTFOR_DEVEL
23 #ifndef _SIMPLE_VECTOR_H_
24 #define _SIMPLE_VECTOR_H_
42 typedef const T *const_iterator;
44 SimpleVector():beginP(NULL),middleP(NULL),endP(NULL) { }
45 SimpleVector(
const SimpleVector &v):
46 beginP(v.beginP),middleP(v.middleP),endP(v.endP) { }
47 explicit SimpleVector(
size_t s):beginP(NULL),middleP(NULL),endP(NULL) {
50 void resize(
size_t s) {
53 if (middleP>endP || size()<capacity()/2)
62 const_iterator begin()
const {
65 const_iterator end()
const {
72 const T &front()
const {
80 const T &back()
const {
85 return size_t(middleP-beginP);
87 size_t capacity()
const {
88 return size_t(endP-beginP);
91 return beginP == endP;
93 T &operator[](
size_t i) {
97 T operator[](
size_t i)
const {
101 void push_back(
const T &v) {
104 doRealloc(s==0?1:2*s);
114 if (size()<capacity()/2)
119 beginP=middleP=endP=NULL;
121 void deallocateAll() {
125 void doRealloc(
size_t s) {
126 size_t i=middleP-beginP;
127 beginP=(T *)realloc(beginP,s*
sizeof(T));
130 assert(middleP<=endP);
136 #endif //DOXYGEN_NOTFOR_DEVEL