lua-users home
lua-l archive

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

Does this affect the time for table.remove( myTable ) which I thought used
to be O(1) once n had been identified?


on 9/2/04 7:29 AM, Roberto Ierusalimschy at wrote:

>> That is, 'table.getn' returns the _last_ integer index, and not the
>> last before 'nil'.
> The new getn returns any integer index before a nil. If the array is
> properly formatted (no "holes") this will be the last index. If the
> array has holes, this index is not well specified. We thought that
> this is as useful (or as useless) as the current smallest index.
> The motivation is that the previous algorithm was O(n),
> while this one is O(log n).
> -- Roberto