Bug fixes + tabbing
[iotcloud.git] / version2 / src / C / vector.h
index ccd86498cc635f9943aa6d3ae5a185bbb6488850..e1378c900e0c447b7b70413f3130024eddc6e4f8 100644 (file)
@@ -31,9 +31,9 @@ public:
        }
 
        void remove(type t) {
-               for (uint i=0; i<fldsize; i++) {
+               for (uint i = 0; i < fldsize; i++) {
                        if (array[i] == t) {
-                               for (i++; i<fldsize; i++) {
+                               for (i++; i < fldsize; i++) {
                                        array[i - 1] = array[i];
                                }
                                fldsize--;
@@ -41,7 +41,14 @@ public:
                        }
                }
        }
-       
+
+       void removeIndex(uint i) {
+               for (i++; i < fldsize; i++) {
+                       array[i - 1] = array[i];
+               }
+               fldsize--;
+       }
+
        type last() const {
                return array[fldsize - 1];
        }
@@ -64,6 +71,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;
@@ -73,6 +86,14 @@ public:
                array[fldsize++] = item;
        }
 
+       type lastElement() {
+               return get(size() - 1);
+       }
+
+       type firstElement() {
+               return get(0);
+       }
+
        type get(uint index) const {
                return array[index];
        }