source: trunk/poppler/mypoppler/goo/GooVector.h @ 257

Last change on this file since 257 was 257, checked in by Eugene Romanenko, 13 years ago

PDF plugin: Poppler library updated to version 0.10.0

File size: 1.5 KB
RevLine 
[257]1//========================================================================
2//
3// This file comes from pdftohtml project
4// http://pdftohtml.sourceforge.net
5//
6// Copyright from:
7// Gueorgui Ovtcharov
8// Rainer Dorsch <http://www.ra.informatik.uni-stuttgart.de/~rainer/>
9// Mikhail Kruk <meshko@cs.brandeis.edu>
10//
11//========================================================================
12
[250]13#ifndef GOO_VECTOR_H
14#define GOO_VECTOR_H
[2]15#include "goo/gtypes.h"
16
17
18template<class T>
19class GooVector{
20private:
21   
22   int _size;
23   T*  last;
24   T*  storage; 
25 
26   void resize(){
27     if (_size==0) _size=2;else _size=2*_size;
28      T *tmp=new T[_size];
29     if (storage){
30       last=copy(storage,last,tmp);
31       delete [] storage;
32      }
33     else last=tmp; 
34     storage=tmp;
35    }
36
[27]37   T* copy(T* src1,T* src2,T* dest){
[2]38     T* tmp=src1;
39     T* d=dest;
[27]40      while(tmp!=src2){
[2]41        *d=*tmp;
42         d++;tmp++;
43       }
44      return d;
45   }
46
47public:
48 typedef T* iterator;
49
50 GooVector(){
51  _size=0;
52  last=0;
53  storage=0;
54}
55
56
57
58virtual ~GooVector(){
59  delete[] storage ;
60} 
61
62void reset(){
63  last=storage;
64}
65
66int size(){
67  return (last-storage);
68}   
69void push_back(const T& elem){
70  if (!storage||(size() >=_size)) resize();
71        *last=elem;
72         last++;
73 
74     
75} 
76
77
78T pop_back() {
79    if (last!=storage) last--;
80
81    return *last;
82} 
83
84
85T operator[](unsigned int i){
86 return *(storage+i);
87}
88 
89
90GBool isEmpty() const{
91 return !_size || (last==storage) ;
92}
93
94
95
96iterator begin() const{
97 return storage;
98}
99
100iterator end() const {
101  return last;
102}
103};
104#endif
105
106
107
108   
109 
110 
111
112
113
Note: See TracBrowser for help on using the repository browser.