The stupid question is the question not asked | |
PerlMonks |
Re: Saving array duplicates, not using a hash?by nobull (Friar) |
on Sep 28, 2008 at 07:20 UTC ( [id://714136]=note: print w/replies, xml ) | Need Help?? |
If the input data is known to be ordered so that duplicates are always adjacent then the problem simplifies to:
When dealing with very large data sets if can make sense to use a highly optimised external sort tool such as GNU sort to put the data into an order that allows you to process it with O(1) memory usage. In this case that is a simple sort. For smaller data sets stick with the usual hash approach. If you happen to know that the data will be sorted anyhow then you can use the hashless approach for smaller data but it is probably not worth it. There is also the option of using Perl's sort but this is usually not a good option.
In Section
Seekers of Perl Wisdom
|
|