lua-users home
lua-l archive

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


On Wednesday 24 March 2004 11:23, Philippe Lhoste wrote:
> I believe you can implement it with arrays, because the table library
> offers functions like table.insert and table.remove. The language offers
> direct access to a value, and the basic library offers iterators.
> This way, you can shift entries as needed.
> I don't know if it is as efficient as a C linked list, but I trust it is
> quite efficient, not moving data around, just indexes.

Using table.insert and table.remove is efficient only if you are using the 
list in lifo (stack) mode, else it can become deadly slow.
Roberto's book ("Programming in Lua") shows a better way to build lists, using 
unbounded arrays. I'd suggest to Phil a reading of that book, to get a better 
understanding of the language.

  Enrico