memcpy(array, _array, capacity * sizeof(type));
}
+ Vector(Vector<type> *v) :
+ size(v->size),
+ capacity(v->capacity),
+ array((type *) ourmalloc(sizeof(type) * v->capacity)) {
+ memcpy(array, v->array, capacity * sizeof(type));
+ }
+
void pop() {
size--;
}
size = _size;
}
- void push(type item) {
+ void addAll(Vector<type> *v) {
+ int oldsize = size;
+ setSize(size + v->size);
+ memcpy(&array[size], v->array, v->size * sizeof(type));
+ }
+
+ void add(type item) {
if (size >= capacity) {
uint newcap = capacity << 1;
array = (type *)ourrealloc(array, newcap * sizeof(type));