|
Well maybe to clarify the question. Would
this be interesting to have kind of array implementation like that? Then ipairs(t) would maybe need a flag
such as ipairs(t, skipnil). typedef struct Page { int actual_beg; // allow to
limit page footprint, and traversal int actual_end; // with
actual_end - actual_beg < PAGESIZE // and
actual_end - actual_beg == PAGESIZE - 1 => actual_beg % PAGESIZE == 0 struct Page* next; // for
traversal TValue data[]; // max size =
PAGESIZE } Page; typdef union { TValue* data; // when sizearray
(index max) < PAGESIZE, with TValue[actual page size] struct BTree* btree; // inserted key
are divint(index/PAGESIZE) } Array; // the worst case is pattern for
i=1,PAGESIZE*1000,PAGESIZE do t[i] = i ; t[i+PAGESIZE-1] = i end typedef struct Table { CommonHeader; lu_byte flags; /* 1<<p means
tagmethod(p) is not present */ lu_byte lsizenode; /* log2 of size of
`node' array */ struct Table *metatable; Array *array; /* array part */ Node *node; Node *lastfree; /* any free position is
before this position */ GCObject *gclist; int sizearray; /* size of `array' array
*/ } Table; From: Hello, I was just wondering why it wasn’t decided to use some
kind of b-tree for array, giving the possibility to manipulate large arrays in
any order of instantiation. Was it considered too memory consuming? |