lua-users home
lua-l archive

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


2013/9/27 Rafis Ganeyev <rafisganeyev@gmail.com>:

> Thank you. When #1 becomes not good to use? For example if
> I have N elements and can delete any of elements with equal
> probability, starting which N #1 becomes not recommended?

This depends on so many things. N=100, no problem; N=1000000,
don't access this as an arrray, better use object-oriented lists such
eg Penlight provides.

> There is also #4 fourth pattern is just to use *pairs()* iterator which
> works on both vector and hash parts, so for completely sparse arrays,
> say { [3] = "abc", [105] = "def", [1032] = "ghi" }, which are stored in
> hash part it is not smart to use numeric *for*.

Careful now, no API routine is supposed to know whether something
is in the vector or in the hash part. 'pairs' and 'ipairs' don't depend on
that in any way. 'pairs'