lua-users home
lua-l archive

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


>From lua-l@tecgraf.puc-rio.br Wed Jul  7 23:19:42 1999
>From: Steve Dekorte <steve@dekorte.com>

>Has anyone written their own list data type or list API?
>Hmmm. If someone wrote a simple API like:
>
> list_new() returns listPointer
> list_insert(void *listPointer, lua_Object item)
> list_remove(listPointer, int index)

if listPointer is the head, how would these not be O(n)?

> list_at(listPointer, int index) returns lua_Object

you have to be careful if you're keeping a list of lua_Object.
you should keep a list of references instead and still be careful unless
you lock everything.
--lhf