tabbing
[iotcloud.git] / version2 / src / C / vector.h
index 8ce18fd6ee283208cc546054db983d1575b80b56..5a7770d2b725cb959ad5679b84b101c589aa374d 100644 (file)
@@ -19,6 +19,13 @@ public:
                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--;
        }
@@ -39,7 +46,13 @@ public:
                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));