ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libptytty/src/estl.h
(Generate patch)

Comparing libptytty/src/estl.h (file contents):
Revision 1.22 by sf-exg, Thu Oct 23 22:45:31 2014 UTC vs.
Revision 1.25 by sf-exg, Mon Oct 27 15:48:04 2014 UTC

37// - no bool specialisation 37// - no bool specialisation
38template<class T> 38template<class T>
39struct simplevec 39struct simplevec
40{ 40{
41#if ESTL_BIG_VECTOR 41#if ESTL_BIG_VECTOR
42 // shoudl use size_t/ssize_t, but that's not portable enough for us 42 // should use size_t/ssize_t, but that's not portable enough for us
43 typedef unsigned long size_type; 43 typedef unsigned long size_type;
44 typedef long difference_type; 44 typedef long difference_type;
45#else 45#else
46 typedef uint32_t size_type; 46 typedef uint32_t size_type;
47 typedef int32_t difference_type; 47 typedef int32_t difference_type;
145 buf = nbuf; 145 buf = nbuf;
146 } 146 }
147 147
148 construct (buf + sze, n); 148 construct (buf + sze, n);
149 149
150 sze += n;
151
152 iterator src = buf + pos; 150 iterator src = buf + pos;
153 if (is_simple_enough ()) 151 if (is_simple_enough ())
154 memmove (src + n, src, sizeof (T) * n); 152 memmove (src + n, src, sizeof (T) * (sze - pos));
155 else 153 else
156 for (size_type i = n; i--; ) 154 for (size_type i = sze - pos; i--; )
157 cop_set (src + n + i, src + i); 155 cop_set (src + n + i, src + i);
156
157 sze += n;
158 } 158 }
159 159
160public: 160public:
161 size_type capacity () const { return res; } 161 size_type capacity () const { return res; }
162 size_type size () const { return sze; } 162 size_type size () const { return sze; }
216 216
217 while (n--) 217 while (n--)
218 new (buf + n) T (t); 218 new (buf + n) T (t);
219 } 219 }
220 220
221 template<class I> 221 simplevec (const_iterator first, const_iterator last)
222 simplevec (I first, I last)
223 { 222 {
224 sze = res = last - first; 223 sze = res = last - first;
225 buf = alloc (sze); 224 buf = alloc (sze);
226 copy (buf, first, sze, cop_new); 225 copy (buf, first, sze, cop_new);
227 } 226 }
267 reference operator [](size_type idx) { return buf[idx]; } 266 reference operator [](size_type idx) { return buf[idx]; }
268 267
269 const_reference at (size_type idx) const { return buf [idx]; } 268 const_reference at (size_type idx) const { return buf [idx]; }
270 reference at (size_type idx) { return buf [idx]; } 269 reference at (size_type idx) { return buf [idx]; }
271 270
272 template<class I> 271 void assign (const_iterator first, const_iterator last)
273 void assign (I first, I last)
274 { 272 {
275 swap (simplevec<T> (first, last)); 273 simplevec<T> v (first, last);
274 swap (v);
276 } 275 }
277 276
278 void assign (size_type n, const T &t) 277 void assign (size_type n, const T &t)
279 { 278 {
280 swap (simplevec<T> (n, t)); 279 simplevec<T> v (n, t);
280 swap (v);
281 } 281 }
282 282
283 simplevec<T> &operator= (const simplevec<T> &v) 283 simplevec<T> &operator= (const simplevec<T> &v)
284 { 284 {
285 assign (v.begin (), v.end ()); 285 assign (v.begin (), v.end ());
294 buf [at] = t; 294 buf [at] = t;
295 295
296 return buf + at; 296 return buf + at;
297 } 297 }
298 298
299 template<class I>
300 iterator insert (iterator pos, I first, I last) 299 iterator insert (iterator pos, const_iterator first, const_iterator last)
301 { 300 {
302 size_type n = last - first; 301 size_type n = last - first;
303 size_type at = pos - begin (); 302 size_type at = pos - begin ();
304 303
305 ins (pos, n); 304 ins (pos, n);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines