lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


RLake@oxfam.org.pe wrote:
>> What I'd like to see is tables storing (internally & invisibly) an
>> offset to the first non-nil key.
>>
> ... but it means that a[k] = nil could take an
> arbitrary amount of time (in order to scan the table to update the
> pointer).

The following would suffice:

1.  Adjust the index _upward_ when appropriate during a lua_next.
2.  Adjust the index _downward_ when setting an earlier field.

In other words, you just keep a sensible lower bound for the first non-nil
field.  Just another thought...  :-)

Bye,
Wim