<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: duplicates code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Mon, 08 Sep 2008 00:26:45 GMT</pubDate>
    <description>DZone Snippets: duplicates code</description>
    <item>
      <title>Efficient 'uniq' snippet</title>
      <link>http://snippets.dzone.com/posts/show/152</link>
      <description>This snippet will quickly uniq an unsorted array; in other words, remove duplicates.   (note: for large arrays, it may be more efficient to sort the array first and simply keep track of consecutive dups instead of using a hash.)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  # Input: @list&lt;br /&gt;  # Output: @uniqed&lt;br /&gt;  my %u = ();&lt;br /&gt;  @uniqed = grep {defined} map {&lt;br /&gt;      if (exists $u{$_}) { undef; } else { $u{$_}=undef;$_; }&lt;br /&gt;    } @list;&lt;br /&gt;  undef %u;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;</description>
      <pubDate>Wed, 13 Apr 2005 03:26:57 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/152</guid>
      <author>jmason (Justin Mason)</author>
    </item>
  </channel>
</rss>
