in reply to Re: count sort & output
in thread count sort & output
any better than a hash?$hot->count("www.yahoo.com","200"); #set to 200 $hot->count("www.yahoo.com","+20"); #add 200 $hot->count("www.yahoo.com"); #increase by 1
$hot{"www.yahoo.com"} = 200; $hot{"www.yahoo.com"} += 20; $hot{"www.yahoo.com"}++
Note also how the latter makes it immediately obvious what's going on - you don't have to look up a classes' behaviour to know what it does.
Lastly, if I did take the OO route for some reason - maybe because I need to pass this around a lot of places in my program, and maybe it does a lot more on-the-fly calculation than just counting mentions, or something - I'd prefer an interface like this:
$hot->count("www.yahoo.com")->set(200); $hot->count("www.yahoo.com")->add(20); $hot->count("www.yahoo.com")->inc;
Makeshifts last the longest.
|
|---|