in reply to Searching parallel arrays.
Sort them into a single array and retain knowledge of where they came from.
i.e. use a hash (or even an array) to map number -> [ $ref_to_source_array, $index_in_source_array ].
Then you can look for a sequence in the sorted array and, for each number in the sequence, look up where it came from.
No code, but it's straightforward I think.
Update: If the memory consumption is excessive, you could encode an identifier for the source array and the index in a single scalar, e.g. "a1:1", "a3:4".
You should then be using about 4 times your original memory, if that's too much you could destroy your original arrays and recreate them afterwards from the lookup info :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Searching parallel arrays.
by jbert (Priest) on Dec 08, 2006 at 11:52 UTC | |
by Not_a_Number (Prior) on Dec 08, 2006 at 16:19 UTC | |
by jbert (Priest) on Dec 08, 2006 at 16:35 UTC |