Source file: /~heha/mb-iwp/bin2graf.zip/src/vector.h

#include <windows.h>	// MoveMemory

template<class T> class vector {
 int elem;
 T *array;
public:
 vector() : elem(0) {}
 vector(int size) : elem(0) {resize(size);}
 ~vector() {resize(0);}

 T& operator[](int i) {return array[i];}

 void resize(int n) {
  if (n) array=(T*)(elem
   ? LocalReAlloc(array,n*sizeof T,LMEM_MOVEABLE|LPTR)
   : LocalAlloc(LPTR,n*sizeof T));
  else if (elem) {
   LocalFree(array);
  }
  elem=n;
 }
 
 void insert(int where, T arg) {
  resize(elem+1);
  MoveMemory(array+where+1,array+where,(elem-1-where)*sizeof T);
  array[where]=arg;
 }

 void push_back(T arg) {insert(elem,arg);}
 
 void erase(int where, int n=1) {
  MoveMemory(array+where,array+where+n,(elem-n-where)*sizeof T);
  resize(elem-n);
 }
 
 void pop_back() {erase(elem-1);}

 int size() const {return elem;}

 operator T*() const {return array;}
};
Detected encoding: ASCII (7 bit)2