Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Count of HoA elements

by ikegami (Patriarch)
on Jan 19, 2007 at 20:15 UTC ( [id://595569]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # time = O(N)   memory = O(N*M)
    
    my $count = map @$_, values %h;
    
  2. or download this
    # time = O(N)   memory = O(N)
    
    my $count = sum map { scalar @$_ } values %h;
    
  3. or download this
    # time = O(N)   memory = O(N)
    
    my $count = 0;
    $count += @$_ for values %h;
    
  4. or download this
    # time = O(N)   memory = O(1)
    
    ...
    while (my ($k, $v) = each(%h)) {
       $count += @$v;
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://595569]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-03-19 10:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found