lua-users home
lua-l archive

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


>From lua-l@tecgraf.puc-rio.br  Mon Jul 31 15:22:09 2000
>From: David Jeske <jeske@chat.net>

>Is getn(a_table) O(1) or O(N)?

O(1) if there's a 'n' field and O(N) otherwise.
If you use tinsert and tremove, then 'n' is updated automatically.

>I'll be much happer with the for loop above that I've been with the
>while() loops in the past. I've forgotten the "i=i+1" at the end of a
>Lua while loop more times than I care to deal with.

That's one reason we introduced 'for'.

>How does Lua walk a hash table? Is it walking the
>hash-space looking for a hit?

Essentially, yes.
--lhf