[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: 'oldindex' metamethod?
- From: Javier Guerra Giraldez <javier@...>
- Date: Fri, 19 Sep 2014 11:50:32 -0500
On Fri, Sep 19, 2014 at 11:17 AM, John Hind <john.hind@zen.co.uk> wrote:
> Admittedly
> some interpretations of the last case might involve some scanning back, if
> you do not want
> to permit holes at the top of the sequence - but that is a little esoteric
not esoteric at all.
imagine you have a 100,000 element array, then decide to keep only the
first 500. the obvious way would be:
for i=501, #t do
t[i] = nil
end
on each iteration, the #t would stay as before on 100,000, until the
very last, where it suddenly would have to scan back 99,500 elements
to find the new end.
--
Javier