Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: best data structure

by rob_au (Abbot)
on Aug 28, 2002 at 13:27 UTC ( [id://193445]=note: print w/replies, xml ) Need Help??


in reply to best data structure

Why not combine the two approaches? The first solution which comes to my mind calls for a single iteration through the elements of @list with a lookup hash, %hash, that is used to avoid duplicate processing.

For example ...

my %hash; while (my $item = shift @list) { next if exists $hash{$item}++; . . }

 

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2024-04-25 05:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found