Ref counting
[iotcloud.git] / version2 / src / C / vector.h
index 438b2361522308cf661884a1cbed2f3c818ff17f..5ca954be06926f5eecc61b4fef1a0e147f5b8baa 100644 (file)
@@ -30,16 +30,17 @@ public:
                fldsize--;
        }
 
-       void remove(type t) {
+       bool remove(type t) {
                for (uint i = 0; i < fldsize; i++) {
                        if (array[i] == t) {
                                for (i++; i < fldsize; i++) {
                                        array[i - 1] = array[i];
                                }
                                fldsize--;
-                               break;
+                               return true;
                        }
                }
+               return false;
        }
 
        void removeIndex(uint i) {
@@ -71,6 +72,12 @@ public:
                memcpy(&array[fldsize], v->array, v->fldsize * sizeof(type));
        }
 
+       void removeAll(Vector<type> *v) {
+               uint vsize = v->size();
+               for (uint i = 0; i < vsize; i++)
+                       remove(v->get(i));
+       }
+
        void add(type item) {
                if (fldsize >= capacity) {
                        uint newcap = capacity << 1;