get unique elements count jquery
<p>I have the following HTML</p>

<pre><code>&lt;input type="hidden" name="product_id" value = "1" class="product_id" /&gt;
&lt;input type="hidden" name="product_id" value = "2" class="product_id" /&gt;
&lt;input type="hidden" name="product_id" value = "5" class="product_id" /&gt;
&lt;input type="hidden" name="product_id" value = "1" class="product_id" /&gt;
&lt;input type="hidden" name="product_id" value = "2" class="product_id" /&gt;
&lt;input type="hidden" name="product_id" value = "2" class="product_id" /&gt;
</code></pre>

<p>How can i get the <code>count</code> of <code>Unique</code> elements (Unique Value of elements) ?</p>

<p>Is this possible <code>without looping</code> ?</p>

<p>Expected Result :</p>

<pre><code>UNIQUE ID  COUNT
-----------------
  1          2  
  2          3
  5          1
</code></pre>

<blockquote>
  <p>What i have tried is something like below, But the problem with this
  approach is that it will loop all the elements.As you can see that on
  first iteration we can understand the count of <code>product_id</code> of <code>1</code>, So it need to skip any other elements with same <code>product_id</code>. I
  have bunch of elements and i will not prefer looping all the elements.</p>
</blockquote>

<pre><code>$(".product_id").each( function(){

  //CHECK THE COUNT AND SAVE IT TO SOME ARRAY

});
</code></pre>

<p>Update :</p>

<blockquote>
  <p>Its Okay to downvote, But it will be very helpful if you put a comment
  for that down vote. I specifically stated <code>without</code> looping because i
  though that sometime it may possible with jQuery's powerfull CSS
  selectors.</p>
</blockquote>
