Re: searching complex datastructures

2003-12-11 Thread wren argetlahm
--- Charlie Garrison [EMAIL PROTECTED] wrote: I'm no expert ( I'd love to hear from one). But when I need to do something similar I use a second data structure for doing the 'reverse lookup'. I thought about that, but was put off by the fact that it's a complex structure-- of course I'm only

Re: searching complex datastructures

2003-12-11 Thread Charlie Garrison
Good afternoon, On 11/12/03 at 4:55 PM -0800, wren argetlahm [EMAIL PROTECTED] wrote: --- Charlie Garrison [EMAIL PROTECTED] wrote: I'm no expert ( I'd love to hear from one). But when I need to do something similar I use a second data structure for doing the 'reverse lookup'. I thought

Re: searching complex datastructures

2003-12-11 Thread Joel Rees
Can anyone offer an elegant solution for a data structure that maintains sorted order as well as access to data for a (primary) key? Is everyone thinking too hard or am I not thinking hard enough? If you have a database and you need to search it on an alternate key, you either linear search on

searching complex datastructures

2003-12-10 Thread wren thornton
I'm working with some complex data (array of hashes in this case) and I'm wondering if there's a good way to do a reverse lookup? So far I have the following: for my $i (0.. @names-1) { if ($names[$i]{'xml_index'} == $xml_index){ $return = $names[$i]{'name'} }

Re: searching complex datastructures

2003-12-10 Thread Charlie Garrison
Good morning, On 10/12/03 at 4:01 PM -0800, wren thornton [EMAIL PROTECTED] wrote: I'm working with some complex data (array of hashes in this case) and I'm wondering if there's a good way to do a reverse lookup? So far I have the following: I'm no expert ( I'd love to hear from one). But when

Re: searching complex datastructures

2003-12-10 Thread Fred Eiden
How about using a different data structure? Maybe a hash of hashes would work better. If the value of $xml_index is unique, then you don't need to use an array to store the list, since you can use the value of $xml_index as the key for your hash. Given a value for $xml_index by the calling