http://www.perlmonks.org?node_id=1070558

BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:

I have a AoA containing a couple of thousand arrays each of which contains 4 non-duplicate, small integers (say 0..19 ). eg.

my @AoA = ( [ 2, 13, 3, 16 ], [ 10, 1, 11, 6 ], [ 0, 10, 11, 19 ], [ 6, 1, 19, 15 ], [ 17, 6, 18, 12 ], ... );

Given that I have selected one of these subarrays (say, the first [ 2, 13, 3, 16 ]),

I then need to iterate the entire AoA to find all those that do not contain any of the integers in the selected subarray.

This needs to be done many times, so I'm looking for a reasonably efficient way to do so. Thoughts?

(I'm thinking about indexing; but how to do so efficiently without consuming huge amounts of space?)


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.