8 template<typename type>
16 Array(uint32_t _size) :
17 array((type *) ourcalloc(1, sizeof(type) * _size)),
22 Array(type *_array, uint _size) :
23 array((type *) ourmalloc(sizeof(type) * _size)),
25 memcpy(array, _array, _size * sizeof(type));
28 Array(Array<type> *_array) :
29 array((type *) ourmalloc(sizeof(type) * _array->size)),
31 memcpy(array, _array->array, size * sizeof(type));
34 void init(uint _size) {
35 array = (type *) ourcalloc(1, sizeof(type) * _size);
39 void init(type *_array, uint _size) {
40 array = (type *) ourmalloc(sizeof(type) * _size);
42 memcpy(array, _array, _size * sizeof(type));
45 void init(Array<type> *_array) {
46 array = (type *) ourmalloc(sizeof(type) * _array->size);
48 memcpy(array, _array->array, size * sizeof(type));
56 bool equals(Array<type> *_array) {
57 if (_array->size != size)
59 int cmp = memcmp(array, _array->array, size * sizeof(type));
63 type get(uint index) const {
67 void set(uint index, type item) {
75 type *internalArray() {
84 template<typename type>
85 void System_arraycopy(Array<type> *src, int32_t srcPos, Array<type> *dst, int32_t dstPos, int32_t len) {
86 if (srcPos + len > src->length() ||
87 dstPos + len > dst->length())
89 uint bytesToCopy = len * sizeof(type);
90 memcpy(&dst->internalArray()[dstPos], &src->internalArray()[srcPos], bytesToCopy);