Perl Monk, Perl Meditation | |
PerlMonks |
Re: Two dimensional sets intersectionby Not_a_Number (Prior) |
on Apr 10, 2013 at 20:44 UTC ( [id://1028038]=note: print w/replies, xml ) | Need Help?? |
No need to worry about narrowing your search or whatever. Hash lookups are fast. The code below creates a hash for a 100 x 100 matrix. It also assumes that each matrix pair has a value (worst case, given your 'spec'). To simplify validation, I make this value 1, but changing it to any other number makes no difference to the time required for lookup. Subsequently, I make another worst-case assumption, namely that your lists of search terms (what you call Subset 1 and Subset 2) are maximally large. On my machine, it finishes before I can blink. Run it and see:
In Section
Seekers of Perl Wisdom
|
|