|
|
||
|
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
I’m pretty sure insert/remove do NOT take linear time, though the time is complex to compute since Lua may or may not have migrated the array to the “array part” of the table. In either case your insert/remove time will be much closer to O(1) than O(n) since the table is based on hashing.