CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [FishMonger] iterate over millions hash entries: Edit Log



skualito92
New User

Apr 13, 2017, 7:15 AM


Views: 8437
Re: [FishMonger] iterate over millions hash entries


In Reply To
You could invert the hash so that the keys are the numbers and the values are array refs of your current keys.

For example, instead of this hash structure:

Code
%hash = ( 
'foo' => 10,
'bar' => 30,
'baz' => 10,
);


You'd have:

Code
%hash = ( 
10 => [ 'foo', 'baz' ],
30 => [ 'bar' ],
);


Then do a normal/typical sort on the keys.


i dont understand why inverting the hash will accelerate the iteration and sorting, except it could reduce the hash size for keys with same value but in my program it will not be the case


(This post was edited by skualito92 on Apr 13, 2017, 7:17 AM)


Edit Log:
Post edited by skualito92 (New User) on Apr 13, 2017, 7:17 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives