6 public class IteratorPointer : struct;
9 extern int __ecereVMethodID_class_OnCompare;
10 extern int __ecereVMethodID_class_OnFree;
13 public struct BuiltInContainer
24 property Container { get { return this; } }
26 virtual IteratorPointer GetFirst() { return data; }
27 virtual IteratorPointer GetLast() { return (IteratorPointer)(data ? ((byte *)data + (count * type.typeSize) - 1) : null); }
28 virtual IteratorPointer GetPrev(IteratorPointer pointer)
30 return (IteratorPointer)((pointer && (byte *)pointer > (byte *)data) ?
31 ((byte *)pointer - ((type.type == noHeadClass || type.type == normalClass) ? sizeof(void *) : type.typeSize)) : null);
33 virtual IteratorPointer GetNext(IteratorPointer pointer)
35 return (IteratorPointer)((pointer && (byte *)pointer < (byte *)data + (count - 1) *
36 ((type.type == noHeadClass || type.type == normalClass) ? sizeof(void *) : type.typeSize) ?
37 ((byte *)pointer + ((type.type == noHeadClass || type.type == normalClass) ? sizeof(void *) : type.typeSize)) : null);
39 virtual uint64 GetData(IteratorPointer pointer)
41 uint64 * item = (uint64 *)pointer;
42 return ((((type.type == structClass) ? ((uint64)item) :
43 (type.type == normalClass || type.type == noHeadClass) ? (uint64)*((void **)item) :
44 ((type.typeSize == 1) ? *((unsigned char *)item) :
45 ((type.typeSize == 2) ? *((unsigned short *)item) :
46 ((type.typeSize == 4) ? *((unsigned int *)item) : *((uint64 *)item)))))));
48 virtual bool SetData(IteratorPointer pointer, uint64 data)
52 virtual IteratorPointer GetAtPosition(uint64 pos, bool create)
54 return data ? (IteratorPointer)((byte *)data +
55 ((type.type == noHeadClass || type.type == normalClass) ? sizeof(void *) : type.typeSize)) : null;
57 virtual IteratorPointer Insert(IteratorPointer after, uint64 value)
61 virtual IteratorPointer Add(uint64 value)
65 virtual void Remove(IteratorPointer it)
68 virtual void Move(IteratorPointer it, IteratorPointer after)
71 virtual void RemoveAll()
74 for(i = GetFirst(); i; i = GetNext(i))
78 virtual void Copy(Container source)
82 virtual IteratorPointer Find(uint64 value)
85 for(i = GetFirst(); i; i = GetNext(i))
87 uint64 data = GetData(i);
89 int result = ((int (*)(void *, void *, void *))(void *)Dclass._vTbl[__ecereVMethodID_class_OnCompare])(Dclass,
90 ((Dclass.type == systemClass && !Dclass.byValueSystemClass) || Dclass.type == bitClass || Dclass.type == enumClass || Dclass.type == unitClass) ? &value : (void *)value,
91 ((Dclass.type == systemClass && !Dclass.byValueSystemClass) || Dclass.type == bitClass || Dclass.type == enumClass || Dclass.type == unitClass) ? &data : (void *)data);
98 virtual void FreeIterator(IteratorPointer it);
99 virtual int GetCount() { return count; }
104 for(i = GetFirst(); i; i = GetNext(i))
105 ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, (void *)GetData(i));
108 virtual void Delete(IteratorPointer it) { }