lua-users home
lua-l archive

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


On Thu, May 7, 2015 at 10:57 AM, Brigham Toskin <brighamtoskin@gmail.com> wrote:
> And even if you're just poking at
> the end position, insert and remove take linear time because the use the #
> operator (or equivalent function?) which counts the entire array from 1
> every time,

Actually, insert and remove appear to use a binary search, so the time
would be logarithmic, not linear.

http://www.lua.org/source/5.3/ltable.c.html#luaH_getn

Called from:

http://www.lua.org/source/5.3/lvm.c.html#luaV_objlen
http://www.lua.org/source/5.3/lapi.c.html#lua_len
http://www.lua.org/source/5.3/lauxlib.c.html#luaL_len
http://www.lua.org/source/5.3/ltablib.c.html#aux_getn
http://www.lua.org/source/5.3/ltablib.c.html#tinsert

-Parke