Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Testing if an array contains a value and then deleting it in most efficient way

by dsheroh (Monsignor)
on Feb 18, 2008 at 17:44 UTC ( [id://668624]=note: print w/replies, xml ) Need Help??


in reply to Testing if an array contains a value and then deleting it in most efficient way

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...)

  • Comment on Re: Testing if an array contains a value and then deleting it in most efficient way

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://668624]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-19 21:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found