lua-users home
lua-l archive

Re: how to work with tables with holes

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


2013年9月26日 Sean Conner <sean@conman.org>:
>
> 1) Don't set an element to nil. Use table.remove() instead.
>
> 2) Use a sentinel value to mark removal.
>
> 3) Keep track of both the size and the maximum index.
>
> In my opintion, the best practice is #1.
If you are using the table as a list (i.e. the exact key does not
matter, but the property "this item comes before that one"
does). Otherwise #2. I agree that 3) is a big-time PITA.

AltStyle によって変換されたページ (->オリジナル) /