edits
[iotcloud.git] / version2 / src / C / array.h
index a456fef5e697d7480addca664d896495ea1fb667..e2e2a67f462c8659ff2272f98c4323c5acd01b33 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef ARRAY_H
 #define ARRAY_H
 #include <inttypes.h>
+#include "common.h"
 
 typedef uint32_t uint;
 
@@ -52,6 +53,13 @@ public:
                        ourfree(array);
        }
 
+       bool equals(Array<type> *_array) {
+               if (_array->size != size)
+                       return false;
+               int cmp = memcmp(array, _array->array, size * sizeof(type));
+               return cmp == 0;
+       }
+
        type get(uint index) const {
                return array[index];
        }
@@ -72,4 +80,13 @@ private:
        type *array;
        uint size;
 };
+
+template<typename type>
+void System_arraycopy(Array<type> *src, int32_t srcPos, Array<type> *dst, int32_t dstPos, int32_t len) {
+       if (srcPos + len > src->length() ||
+                       dstPos + len > dst->length())
+               ASSERT(0);
+       uint bytesToCopy = len * sizeof(type);
+       memcpy(&dst->internalArray()[dstPos], &src->internalArray()[srcPos], bytesToCopy);
+}
 #endif