|
Posted by Kevin Brammer on June 17, 2008, 11:48 am
Please log in for more thread options
nolo contendere wrote:
> [snip]
> For the record, I agree with bugbear that a more appropriate data
> structure would be a hash of arrays.
Thanks for the replies everyone.
The only problem with a hash of arrays is I need to be able to lookup
the values by name. For example, I need to be able to pull 00-00AAAA,
entry2 ($HoH) independently. I suppose I could go
searching through the array for the particular hash item, but it just
seems more efficient to call it.
Kevin
|
|
Posted by xhoster on June 17, 2008, 2:55 pm
Please log in for more thread options
> nolo contendere wrote:
>
> > [snip]
> > For the record, I agree with bugbear that a more appropriate data
> > structure would be a hash of arrays.
>
> Thanks for the replies everyone.
>
> The only problem with a hash of arrays is I need to be able to lookup
> the values by name. For example, I need to be able to pull 00-00AAAA,
> entry2 ($HoH) independently.
But people are suggesting a hash of array, not an array of array.
You have:
$HoH
you could do:
$HoA[$entry_as_actual_number]
> I suppose I could go
> searching through the array for the particular hash item, but it just
> seems more efficient to call it.
Maybe your real world second level structure isn't as simple as your
example "entry1", "entry2", "entry3" and they have real meaningful names
instead, or maybe that format is mandated by some other part of the code
you can't change, but generally I'd say you should strip off the silly
"entry" part and just use the numeric part (but changing them to start with
0 rather than 1), and then since you are using integers, use an array
rather than a hash for the second level. The first level, of course, stays
a hash.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
|
|
Posted by Kevin Brammer on June 17, 2008, 11:49 am
Please log in for more thread options nolo contendere wrote:
> [snip]
> For the record, I agree with bugbear that a more appropriate data
> structure would be a hash of arrays.
Thanks for the replies everyone.
The only problem with a hash of arrays is I need to be able to lookup
the values by name. For example, I need to be able to pull 00-00AAAA,
entry2 ($HoH) independently. I suppose I could go
searching through the array for the particular hash item, but it just
seems more efficient to call it.
Kevin
|
|
Posted by Kevin Brammer on June 17, 2008, 11:49 am
Please log in for more thread options nolo contendere wrote:
> [snip]
> For the record, I agree with bugbear that a more appropriate data
> structure would be a hash of arrays.
Thanks for the replies everyone.
The only problem with a hash of arrays is I need to be able to lookup
the values by name. For example, I need to be able to pull 00-00AAAA,
entry2 ($HoH) independently. I suppose I could go
searching through the array for the particular hash item, but it just
seems more efficient to call it.
Kevin
|
|
Posted by nolo contendere on June 17, 2008, 11:56 am
Please log in for more thread options wrote:
> nolo contendere wrote:
>
> =A0> [snip]
>
> > For the record, I agree with bugbear that a more appropriate data
> > structure would be a hash of arrays.
>
> Thanks for the replies everyone.
>
> The only problem with a hash of arrays is I need to be able to lookup
> the values by name. =A0For example, I need to be able to pull 00-00AAAA,
> entry2 ($HoH) =A0independently. =A0I suppose I could go
> searching through the array for the particular hash item, but it just
> seems more efficient to call it.
>
Right, but you're artificially creating the "entry0", "entry1"...key
in your hash. So you are doing more work than you need since that
could more easily be the array index.
|
| Similar Threads | Posted | | Performance Improvement of complex data structure (hash of hashes of hashes) | August 24, 2004, 2:26 pm |
| Re: Performance Improvement of complex data structure (hash of hashes of hashes) | August 25, 2004, 10:49 am |
| Re: Performance Improvement of complex data structure (hash of hashes of hashes) | August 26, 2004, 7:19 am |
| Re: Performance Improvement of complex data structure (hash of hashes of hashes) | August 26, 2004, 7:26 am |
| "Pseudo-hashes are deprecated" error and accessing a hash of hashes | January 30, 2006, 4:04 pm |
| Hash of hashes, of hashes, of arrays of hashes | October 27, 2005, 6:05 pm |
| Hashes of hashes or just one hash ? | June 8, 2005, 6:09 am |
| Sorting a hash containing a hash of hashes | December 14, 2005, 2:29 pm |
| Help with Hash of Hashes | March 1, 2006, 1:54 pm |
| Hash of hashes | April 10, 2006, 5:15 pm |
|