lua-users home
lua-l archive

suggestion: table.remove and non-integer keys

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


Hi all.
I deal with some really large strings i have to sort in some way and finally create a concatinated result string. The string content doesnt change.
I store the strings in a table using non integer keys. (eg.: file names)
I dont want to make copies of the strings because they are large.
Finally i create a sorted table with integer keys and do a table.concat to create the
really large result string.
Now the problem:
i want to move a string without making a copy
from a table '[string] = string"' to a table '[int] = string'.
table.remove() doesnt work because it requests integer keys.
So i do a simple asignment;
 td[int] = ts["key"];
 ts["key"] = nil;
As far as i know this creates a copy of the value-sting.
My question/ suggestion:
Why not allow string keys in table.remove?
Simply remove one entry from the table without shifting around other entries.
Any pros and cons? I overlooked something?
Thanks.
Ulrich.

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