lua-users home
lua-l archive

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


On 14/12/2010 9.34, Axel Kittenberger wrote:
As far I understood this proposal table.remove(t) has O(n) costs.
Since

t[500] = 1
t[750] = 1
t[1000] = 1
table.remove(t)
now it has to scan all values to find the largest, 750.

If I understood Keith's proposal correctly, #t would just be 999; there would be no guarantee of it pointing to a non-nil value (in fact, that's done exactly to allow nil values to be counted as valid array entries).

--
  Enrico