lua-users home
lua-l archive

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


Enrico Colombini <erix@erix.it> wrote:
(24/06/2009 21:49)

>lostgallifreyan wrote:
>> Suppose you have a LONG table full of several thousand NMEA 
> > sentences or whatever.. If you need to thin data in place
> > according to some rule, you need table.remove().
> > But if you use ipairs() you work forwards from index 1.
>
>I'm not sure I'd use a simple flat table in a case like this. Maybe a 
>linked list or some other structure could be more appropriate, depending 
>on the frequency of operations and their relative cost.
>

I need the elements to always be in the same order, but a linked list is better when I don't. Also, on Wikipedia: "On the other hand, linked lists by themselves do not allow random access to the data, or any form of efficient indexing. Thus, many basic operations ? such as obtaining the last node of the list, or finding a node that contains a given data, or locating the place where a new node should be inserted ? may require scanning most of the list elements." I need frequent indexing at speed so Lua's tables work well as intended for this.