title: How to count duplicate entries of a vector in C++
body: <p>I'm using Armadillo to do linear algebra calculation in C++. </p>
  
  <p>For example, there is a </p>
  
  <pre><code>vector a = (1,1,2,2,0,2,1,0)
  </code></pre>
  
  <p>I wish return a matrix</p>
  
  <pre><code>(0, 2) //means 0 shows 2 times in the vector
  (1, 3) //1 shows 3 times
  (2, 3) //2 shows 3 times
  </code></pre>
  
  <p>Is there any function can fulfill such job?</p>