in reply to fastest way to compare two arrays

krusty:

Two questions:

  1. Do you really need to use an array?
  2. Do you really need the lowest-numbered available port?

If the answer is no for both, you might consider using a hash to hold your free ports. So when you want to use a free port, just grab the first available one without sorting, and remove it from the "available" hash. When you're done with it, just return it to the hash.

If you must use an array, but don't need the lowest-numbered port, then just pop a port from your list, and when you're done with it, push it back on.

...roboticus

When your only tool is a hammer, all problems look like your thumb.