|
@@ -157,7 +157,7 @@
|
157
|
157
|
* For complex data type vectors, this is more space-efficient than the copy \
|
158
|
158
|
* performed by insert. \
|
159
|
159
|
*/ \
|
160
|
|
- void prefix##insert_r##suffix(struct_name* v, vector_type* p, const vector_type* val); \
|
|
160
|
+ void prefix##insert_r##suffix(struct_name* v, vector_type* p, const vector_type* v); \
|
161
|
161
|
\
|
162
|
162
|
/* \
|
163
|
163
|
* Inserts the range of values in [first, last), before the pointer passed. \
|
|
@@ -344,15 +344,22 @@
|
344
|
344
|
} \
|
345
|
345
|
*(it + 1) = *it; \
|
346
|
346
|
*p = *val; \
|
347
|
|
- }
|
|
347
|
+ } \
|
348
|
348
|
\
|
349
|
|
- /* \
|
350
|
|
- * Inserts the range of values in [first, last), before the pointer passed. \
|
351
|
|
- */ \
|
352
|
|
- void prefix##insert_range##suffix(struct_name* v, vector_type* p, const vector_type* begin, const vector_type* end); \
|
|
349
|
+ void prefix##insert_range##suffix(struct_name* v, vector_type* p, const vector_type* begin, const vector_type* end) { \
|
|
350
|
+ if(avail == tail) { \
|
|
351
|
+ prefix##grow##suffix(v, prefix##capacity##suffix(v) + 1); \
|
|
352
|
+ } \
|
|
353
|
+ vector_type* it = a + (prefix##size##suffix(v) - 1); \
|
|
354
|
+ size_t sz = end - begin; \
|
|
355
|
+ for(; it > p; --it) { \
|
|
356
|
+ *(it + sz) = *it; \
|
|
357
|
+ } \
|
|
358
|
+ *(it + sz) = *it; \
|
|
359
|
+ /* Copy [begin, end) into [p, p + sz) */ \
|
|
360
|
+ algorithm_min_copy(vector_type*, begin, end, p); \
|
|
361
|
+ } \
|
353
|
362
|
\
|
354
|
|
-
|
355
|
|
-
|
356
|
363
|
void prefix##pop_back##suffix(struct_name* v) { \
|
357
|
364
|
assert(prefix##size##suffix(v) != 0); \
|
358
|
365
|
--v->avail; \
|