The stupid question is the question not asked | |
PerlMonks |
Re: Testing if an array contains a value and then deleting it in most efficient wayby dsheroh (Monsignor) |
on Feb 18, 2008 at 17:44 UTC ( [id://668624]=note: print w/replies, xml ) | Need Help?? |
I'll put in another vote for "use a hash instead of an array" unless there's some reason that the order of the values needs to be preserved.
If the order that you'll need the values is predictable, you may also be able to have the database pre-sort them for you so that you can just shift values out of the array. One sort will almost always be faster than 10,000 searches. (Especially since those searches will have to be done in extremely-ineffecient ways unless the data is sorted first...)
In Section
Seekers of Perl Wisdom
|
|