![]() |
hash of hash of hash of hash in c++
Hello,
is it possible to write the below Perl code in C++ ? The code creates a hash which contains hashes of hashes of hashes which contain a key called "count" which is incremented if it exists. Thanks for your help. rp ----------------------------------------- #!/opt/local/bin/perl use strict; use warnings; my %hash = (); for (my $y = 2000; $y < 2010; ++$y) { for (my $m = 1; $m < 12; ++$m) { for (my $d = 1; $d < 30; ++$d) { process(\%hash, $y, $m, $d); } } } for (my $y = 2000; $y < 2010; ++$y) { for (my $m = 1; $m < 12; ++$m) { for (my $d = 1; $d < 30; ++$d) { process(\%hash, $y, $m, $d); } } } use Data::Dump qw(dump); print dump(%hash); sub process { my ($hash_ref,$y,$m,$d) = @_; if ( exists ${$hash_ref}{$y}{$m}{$d}{count} ) { ${$hash_ref}{$y}{$m}{$d}{count}++; } else { ${$hash_ref}{$y}{$m}{$d}{count} = 0; } } |
Re: hash of hash of hash of hash in c++
On 11/9/2011 11:12 PM, rp wrote:
> Hello, > is it possible to write the below Perl code in C++ ? Yes. |
| All times are GMT. The time now is 09:47 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.