Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: a5865dae5b
Fetching contributors…

Cannot retrieve contributors at this time

file 110 lines (78 sloc) 1.577 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
//========================================================================
//
// This file comes from pdftohtml project
// http://pdftohtml.sourceforge.net
//
// Copyright from:
// Gueorgui Ovtcharov
// Rainer Dorsch <http://www.ra.informatik.uni-stuttgart.de/~rainer/>
// Mikhail Kruk <meshko@cs.brandeis.edu>
//
//========================================================================

#ifndef GOO_VECTOR_H
#define GOO_VECTOR_H
#include "goo/gtypes.h"


template<class T>
class GooVector{
private:
   
   int _size;
   T* last;
   T* storage;
 
   void resize(){
     if (_size==0) _size=2;else _size=2*_size;
      T *tmp=new T[_size];
     if (storage){
       last=copy(storage,last,tmp);
       delete [] storage;
      }
     else last=tmp;
     storage=tmp;
    }

   T* copy(T* src1,T* src2,T* dest){
     T* tmp=src1;
     T* d=dest;
      while(tmp!=src2){
        *d=*tmp;
         d++;tmp++;
       }
      return d;
   }

public:
 typedef T* iterator;

 GooVector(){
  _size=0;
  last=0;
  storage=0;
}



virtual ~GooVector(){
  delete[] storage ;
}

void reset(){
  last=storage;
}

int size(){
  return (last-storage);
}
void push_back(const T& elem){
  if (!storage||(size() >=_size)) resize();
        *last=elem;
         last++;
  
     
}


T pop_back() {
    if (last!=storage) last--;

    return *last;
}


T operator[](unsigned int i){
 return *(storage+i);
}
  

GBool isEmpty() const{
 return !_size || (last==storage) ;
}



iterator begin() const{
 return storage;
}

iterator end() const {
  return last;
}
};
#endif



   
  
  
Something went wrong with that request. Please try again.