~ubuntu-branches/ubuntu/lucid/lcdf-typetools/lucid

« back to all changes in this revision

Viewing changes to include/lcdf/vector.hh

  • Committer: Bazaar Package Importer
  • Author(s): C.M. Connelly
  • Date: 2009-04-06 16:49:02 UTC
  • mfrom: (1.2.8 upstream) (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090406164902-9mu14sman9wo3112
Tags: 2.78-1
* New upstream release.
* t1lint: Report warnings when a font charstring command has too many
  arguments.
* Font library changes: correctly implement binary search in a couple
  places -- unexpected sizes could lead to overflow and bad behavior.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
  typedef const T& const_reference;
19
19
  typedef T* pointer;
20
20
  typedef const T* const_pointer;
21
 
  
 
21
 
22
22
  typedef int size_type;
23
 
  
 
23
 
24
24
  typedef T* iterator;
25
25
  typedef const T* const_iterator;
26
 
  
 
26
 
27
27
  explicit Vector()             : _l(0), _n(0), _capacity(0) { }
28
28
  explicit Vector(size_type n, const T &e) : _l(0), _n(0), _capacity(0) { resize(n, e); }
29
29
  // template <class In> ...
33
33
  Vector<T>& operator=(const Vector<T>&);
34
34
  Vector<T>& assign(size_type n, const T& e = T());
35
35
  // template <class In> ...
36
 
  
 
36
 
37
37
  // iterators
38
38
  iterator begin()                      { return _l; }
39
39
  const_iterator begin() const          { return _l; }
66
66
  iterator erase(iterator, iterator);
67
67
  void swap(Vector<T> &);
68
68
  void clear()                          { erase(begin(), end()); }
69
 
  
 
69
 
70
70
 private:
71
 
  
 
71
 
72
72
  T *_l;
73
73
  size_type _n;
74
74
  size_type _capacity;
112
112
  typedef void* const* const_pointer;
113
113
 
114
114
  typedef int size_type;
115
 
  
 
115
 
116
116
  typedef void** iterator;
117
117
  typedef void* const* const_iterator;
118
118
 
120
120
  explicit Vector(size_type n, void* e) : _l(0), _n(0), _capacity(0) { resize(n, e); }
121
121
  Vector(const Vector<void*> &);
122
122
  ~Vector();
123
 
  
 
123
 
124
124
  Vector<void*> &operator=(const Vector<void*> &);
125
125
  Vector<void*> &assign(size_type n, void* e = 0);
126
 
  
 
126
 
127
127
  // iterators
128
128
  iterator begin()                      { return _l; }
129
129
  const_iterator begin() const          { return _l; }
158
158
  void clear()                          { _n = 0; }
159
159
 
160
160
 private:
161
 
  
 
161
 
162
162
  void **_l;
163
163
  size_type _n;
164
164
  size_type _capacity;
181
181
  --_n;
182
182
}
183
183
 
184
 
inline Vector<void*>::iterator 
 
184
inline Vector<void*>::iterator
185
185
Vector<void*>::erase(Vector<void*>::iterator e)
186
186
{
187
187
  return (e < end() ? erase(e, e + 1) : e);
190
190
 
191
191
template <class T>
192
192
class Vector<T*>: private Vector<void*> {
193
 
  
 
193
 
194
194
  typedef Vector<void*> Base;
195
 
  
 
195
 
196
196
 public:
197
197
 
198
198
  typedef T* value_type;
202
202
  typedef T* const* const_pointer;
203
203
 
204
204
  typedef int size_type;
205
 
  
 
205
 
206
206
  typedef T** iterator;
207
207
  typedef T* const* const_iterator;
208
 
  
 
208
 
209
209
  explicit Vector()                     : Base() { }
210
210
  explicit Vector(size_type n, T* e)    : Base(n, (void *)e) { }
211
211
  Vector(const Vector<T *> &o)          : Base(o) { }
212
212
  ~Vector()                             { }
213
213
 
214
214
  Vector<T *> &operator=(const Vector<T *> &o)
215
 
                { Base::operator=(o); return *this; }
 
215
                { Base::operator=(o); return *this; }
216
216
  Vector<T *> &assign(size_type n, T *e = 0)
217
 
                { Base::assign(n, (void *)e); return *this; }
218
 
  
 
217
                { Base::assign(n, (void *)e); return *this; }
 
218
 
219
219
  // iterators
220
220
  const_iterator begin() const  { return (const_iterator)(Base::begin()); }
221
221
  iterator begin()              { return (iterator)(Base::begin()); }
240
240
  T* back() const               { return (T*)(Base::back()); }
241
241
  T*& at_u(size_type i)         { return (T*&)(Base::at_u(i)); }
242
242
  T* at_u(size_type i) const    { return (T*)(Base::at_u(i)); }
243
 
  
 
243
 
244
244
  // modifiers
245
245
  void push_back(T* e)          { Base::push_back((void*)e); }
246
246
  void pop_back()               { Base::pop_back(); }
248
248
  iterator erase(iterator i, iterator j) { return Base::erase((void**)i, (void**)j); }
249
249
  void swap(Vector<T *> &o)     { Base::swap(o); }
250
250
  void clear()                  { Base::clear(); }
251
 
    
 
251
 
252
252
};
253
253
 
254
254
#include <lcdf/vector.cc>       // necessary to support GCC 3.3