[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Changes to table length
- From: Martin <eden_martin_fuhrspam@...>
- Date: Sat, 20 Aug 2016 17:01:47 -0700
On 16-08-20 03:34 AM, Soni L. wrote:
> Each C API function
> should handle length on its own way.
Ok.
1. Will "table.insert(t, el)" and "t[#t+ 1] = el" remain equivalent?
2. Can you offer length algorithm that is O(1). Id est consumes constant
time to determine sequence length of table?
2.1 Because something like
local len = 1
while (t[len] ~= nil) do
len = len + 1
end
return len
is O(n) and behaves like C's strlen().
I'm getting tired or assertions that Lua "should" something. It's not.