//#define ARRAY ((IncrementArrayImpl)this).array // //public import "ecere" // //default: //extern int __ecereVMethodID_class_OnFree; // //private: // //class IncrementArrayImpl //{ // uint count; // uint size; // uint increment; // uint divider; // Class type; // byte * array; //}; // //default: //extern int __ecereVMethodID_class_OnFree; // // ~Array() // { // // what's up with that? // //int c; // //void ** array = (void **)((ArrayImpl)this).array; // //if(type.type == normalClass || type.type == noHeadClass) // { // //for(c = 0; c size) // memset(array + size * GetTypeSize(), 0, (value - size) * GetTypeSize()); // // // the following after the MoveBytes in Array's Remove function // FillBytes(incarray + count, 0, GetTypeSize()); // why set to 0 and is it even correct code // /* class DerivedArray : Array { uint dummy; } class IntDerivedArray : DerivedArray { type = class(int); offset = offsetof(_); public: int * const _; } */ /* #define ARRAY ((IndexedIncrementArrayImpl)this).array public import "ecere" default: extern int __ecereVMethodID_class_OnFree; private: public class IndexedIncrementArray : public IncrementArray { UintIncrementArray index { }; public: property uint count { set { if(value != _count) { if((value / _increment + 1) * _increment != _size) size = value ? (value / _increment + 1) * _increment : 0; index.count = _count; _count = value; } } get { return _count; } } property uint size { set { if(value != _size) { if(ARRAY) { ARRAY = renew ARRAY byte[value * GetTypeSize()]; if(value > _size) // this is initializing to 0, right?, do I want that? // why memset instead of FillBytes? memset(ARRAY + _size * GetTypeSize(), 0, (value - _size) * GetTypeSize()); } else if(value) ARRAY = new byte[value * GetTypeSize()]; index.size = _size; _size = value; } } get { return _size; } } property uint increment { set { _increment = value; } get { return _increment; } } property void * data { set { memcpy(ARRAY, value, _size * GetTypeSize()); } } void Append(int n) { count += n; } void Insert(uint position, int n) { Append(n); if(position < _count - 1) MoveBytes(ARRAY + position + n, ARRAY + position, (_count - position - n) * GetTypeSize()); } void Trim(int n) { count -= n; } void Remove(uint position, int n) { if(position + n - 1 < _count - 1) MoveBytes(ARRAY + position, ARRAY + position + n, (_count - position - n) * GetTypeSize()); //FillBytes(ARRAY + _count, 0, GetTypeSize()); // why set to 0 and is it even correct code Trim(n); } }; class IntIndexedIncrementArray : IndexedIncrementArray { type = class(int); public: int * const _; } class UintIndexedIncrementArray : IndexedIncrementArray { type = class(uint); public: uint * const _; uint * Add(int item) { uint pos = _count; Append(1); _[pos] = item; return &_[pos]; } uint * AddBefore(uint position, int item) { Insert(position, 1); _[position] = item; return &_[position]; } } class StringIndexedIncrementArray : IndexedIncrementArray { type = class(String); public: String * const _; String * Add(String item) { uint pos = _count; Append(1); _[pos] = item; return &_[pos]; } String * AddBefore(uint position, String item) { Insert(position, 1); _[position] = item; return &_[position]; } } */ /* class UIntBIArray : IncArray { type = class(uint); public: uint * const _; uint * Add(uint item) { uint pos = _count; Append(1); _[pos] = item; return &_[pos]; } uint * AddBefore(uint position, uint item) { Insert(position, 1); _[position] = item; return &_[position]; } } */ /* class UintSortArray : IncArray { type = class(uint); public: uint * const _; uint * Add(uint item) { uint pos = _count; Append(1); _[pos] = item; return &_[pos]; } uint * AddBefore(uint position, uint item) { Insert(position, 1); _[position] = item; return &_[position]; } } public class SortArray : IncArray { UintIncArray index; } define array = ((SortArrayImpl)this).a; class SortArrayImpl { uint _size; uint _count; uint _increment; Class type; byte * a; }; public class SortArray { uint _size; uint _count; uint _increment; ~SortArray() { delete array; } public: Class type; property uint count { set { if(value != _count) { int newsize = (value / _increment + 1) * _increment; if(newsize != _size) size = value ? newsize : 0; _count = value; } } get { return _count; } } 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 uint increment { set { _increment = value; } get { return _increment; } } property void * data { set { memcpy(array, value, _size * sizeoftype); } } void Append(int n) { count += n; } void Insert(uint position, int n) { Append(n); if(position < _count - 1) MoveBytes(array + (position + n) * sizeoftype, array + position * sizeoftype, (_count - position - n) * sizeoftype); } void Trim(int n) { count -= n; } void Remove(uint position, int n) { if(position + n - 1 < _count - 1) MoveBytes(array + position * sizeoftype, array + (position + n) * sizeoftype, (_count - position - n) * sizeoftype); Trim(n); } }; */ /*int CompareInt(uint a, uint b) { return (a > b) ? 1 : ((a < b) ? - 1 : 0); }*/ /*int CompareString(char * a, char * b) { return (a && b) ? Compare(a, b) : -1; }*/ //void ::FreeString(char * string)