[Date Prev][Date Next][Thread Prev][Thread Next]
- 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.
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
is O(n) and behaves like C's strlen().
I'm getting tired or assertions that Lua "should" something. It's not.