1 //#define ARRAY ((IncrementArrayImpl)this).array
3 //public import "ecere"
6 //extern int __ecereVMethodID_class_OnFree;
10 //class IncrementArrayImpl
21 //extern int __ecereVMethodID_class_OnFree;
25 // // what's up with that?
27 // //void ** array = (void **)((ArrayImpl)this).array;
28 // //if(type.type == normalClass || type.type == noHeadClass)
30 // //for(c = 0; c<size; c++)
31 // //type._vTbl[__ecereVMethodID_class_OnFree](type, array[c]);
33 // // TODO: Call OnFree for structClass
37 // // the following after the renew in Array's size property
39 // memset(array + size * GetTypeSize(), 0, (value - size) * GetTypeSize());
41 // // the following after the MoveBytes in Array's Remove function
42 // FillBytes(incarray + count, 0, GetTypeSize()); // why set to 0 and is it even correct code
46 class DerivedArray : Array
51 class IntDerivedArray : DerivedArray
61 #define ARRAY ((IndexedIncrementArrayImpl)this).array
66 extern int __ecereVMethodID_class_OnFree;
70 public class IndexedIncrementArray : public IncrementArray
72 UintIncrementArray index { };
81 if((value / _increment + 1) * _increment != _size)
82 size = value ? (value / _increment + 1) * _increment : 0;
87 get { return _count; }
97 ARRAY = renew ARRAY byte[value * GetTypeSize()];
99 // this is initializing to 0, right?, do I want that?
100 // why memset instead of FillBytes?
101 memset(ARRAY + _size * GetTypeSize(), 0, (value - _size) * GetTypeSize());
104 ARRAY = new byte[value * GetTypeSize()];
109 get { return _size; }
111 property uint increment { set { _increment = value; } get { return _increment; } }
116 memcpy(ARRAY, value, _size * GetTypeSize());
123 void Insert(uint position, int n)
126 if(position < _count - 1)
127 MoveBytes(ARRAY + position + n, ARRAY + position, (_count - position - n) * GetTypeSize());
133 void Remove(uint position, int n)
135 if(position + n - 1 < _count - 1)
136 MoveBytes(ARRAY + position, ARRAY + position + n, (_count - position - n) * GetTypeSize());
137 //FillBytes(ARRAY + _count, 0, GetTypeSize()); // why set to 0 and is it even correct code
142 class IntIndexedIncrementArray : IndexedIncrementArray
149 class UintIndexedIncrementArray : IndexedIncrementArray
162 uint * AddBefore(uint position, int item)
170 class StringIndexedIncrementArray : IndexedIncrementArray
172 type = class(String);
176 String * Add(String item)
183 String * AddBefore(uint position, String item)
194 class UIntBIArray : IncArray
199 uint * Add(uint item)
206 uint * AddBefore(uint position, uint item)
216 class UintSortArray : IncArray
221 uint * Add(uint item)
228 uint * AddBefore(uint position, uint item)
236 public class SortArray : IncArray
243 define array = ((SortArrayImpl)this).a;
254 public class SortArray
273 int newsize = (value / _increment + 1) * _increment;
275 size = value ? newsize : 0;
279 get { return _count; }
290 array = renew array byte[value * sizeoftype];
295 array = new byte[value * sizeoftype];
299 get { return _size; }
301 property uint increment { set { _increment = value; } get { return _increment; } }
306 memcpy(array, value, _size * sizeoftype);
313 void Insert(uint position, int n)
316 if(position < _count - 1)
317 MoveBytes(array + (position + n) * sizeoftype, array + position * sizeoftype, (_count - position - n) * sizeoftype);
323 void Remove(uint position, int n)
325 if(position + n - 1 < _count - 1)
326 MoveBytes(array + position * sizeoftype, array + (position + n) * sizeoftype, (_count - position - n) * sizeoftype);
332 /*int CompareInt(uint a, uint b)
334 return (a > b) ? 1 : ((a < b) ? - 1 : 0);
337 /*int CompareString(char * a, char * b)
339 return (a && b) ? Compare(a, b) : -1;
342 //void ::FreeString(char * string)