The idea is to basically use a dynamic array for most of the items, then an array to get the rest.

T[] Base;
T[int] Rest;

Then if Base has a max size(usually it might be fixed due to some algorithm) the Rest AA can pick up any outside values easily.

The idea here is to be able to combine them as one "infinite" array of T.

Any indexing outside of Base gets carried in to Rest.

Now the question is, is there any way to wrap all this in to dynamic array semantics easily?

In fact, we might want to have ranges of indices that are relatively dense handled by several Bases and then sparse ranges handled by the Rest. If the structure is nice we can just nest it.

E.g.,

InfArray(InfArray(min1, max1),min2,max2)

would have two bases, one that handles [min1...max1) and then [min2..max2) and then has one or two Rest's for the rest of the values(not sure if we could probably use a single AA sense it might be used for something else or not, could make it optional to reference the same array).

This sorta gets one that best of both worlds, in fact, I wonder if a programming language could use such a thing(I think Lua probably is based on this idea with it's table's?).


Reply via email to