lua-users home
lua-l archive

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


Hi to all.

I have the following scenario, a pretty usual one i suppose, and was
wondering for the cleanest solution.

I have a dictionary, keyed by strings and value-d with pretty involved
tables. I will iterate all the entries frequently (so no proxying
tables) and in addition i want to enforce a maximum number of entries.
The pseudo pseudo code goes something like "if there's space in the
table add the entry, else search for one entry to be replaced". 

So i would like to have a way for knowing how many entries are already
in the dictionary without having to iterate everything.

The best idea i have is pretty ad-hoc, to lazily count the entries in
some iteration i already have to perform (i have certain latitude with
numbers).

Thanks in advance,

Jorge