public import "ecere" import "ArrayUtilities" private: define array = ((BasicArrayImpl)this).a; class BasicArrayImpl { uint _size; Class type; byte * a; }; public class BasicArray { uint _size; ~BasicArray() { delete array; } public: Class type; property uint size { set { if(value != _size) { if(array) { if(value) array = renew array byte[value * sizeoftype]; else delete array; } else if(value) array = new byte[value * sizeoftype]; _size = value; } } get { return _size; } } property void * data { set { memcpy(array, value, _size * sizeoftype); } } void Append(int n) { size += n; } void Insert(uint position, int n) { Append(n); if(position < _size - 1) MoveBytes(array + (position + n) * sizeoftype, array + position * sizeoftype, (_size - position - n) * sizeoftype); } void Trim(int n) { size -= n; } void Remove(uint position, int n) { if(position + n - 1 < _size - 1) MoveBytes(array + position * sizeoftype, array + (position + n) * sizeoftype, (_size - position - n) * sizeoftype); Trim(n); } }; public class IntBasicArray : BasicArray { type = class(int); public: int * const _; uint * Add(int item) { uint pos = _size; Append(1); _[pos] = item; return &_[pos]; } uint * AddBefore(uint position, int item) { Insert(position, 1); _[position] = item; return &_[position]; } } public class UintBasicArray : BasicArray { type = class(uint); public: uint * const _; uint * Add(uint item) { uint pos = _size; Append(1); _[pos] = item; return &_[pos]; } uint * AddBefore(uint position, uint item) { Insert(position, 1); _[position] = item; return &_[position]; } } public class StringBasicArray : BasicArray { type = class(String); public: String * const _; String * Add(String item) { uint pos = _size; Append(1); _[pos] = item; return &_[pos]; } String * AddBefore(uint position, String item) { Insert(position, 1); _[position] = item; return &_[position]; } }