title: Insert in stl set
body: <p>I need to keep a collection of integers in a priority_queue. However I need to be able to remove one of these integers even if it's not the first element of my container. I couldn't use std::priority_queue. 
  I chose to use a set which would keep the integers sorted <strong>based on a custom comparator</strong>. </p>
  
  <pre><code>class Comparator
  {
      vector&lt;double&gt;&amp; cmp;
      public:
      Comparator(vector&lt;double&gt;&amp; a_cmp) : cmp(a_cmp) {}
      bool operator() (int i, int j) const {return cmp.at(i) &lt; cmp.at(j);}
  };
  </code></pre>
  
  <p>I then used the set like this : </p>
  
  <pre><code>Comparator comp = Comparator(a_cmp);
  set&lt;int, Comparator&gt; my_set (comp);
  my_set.insert(index);
  </code></pre>
  
  <p>However it appears that for two integers i and j such as i != j and cmp.at(i) == cmp.at(j), if I try to insert both, only one would be inserted into the set. 
  I understand that it is the behaviour of std::set, however I would have prefered if both those integers (which are not equals) would be inserted in the set next to each other. 
  In other words I need my custom comparator to be used when sorting the set but not to prevent insertions.
  I think it may work when I modify my comparison function for:</p>
  
  <pre><code>bool operator() (int i, int j) const {return cmp.at(i) =&lt; cmp.at(j);}
  </code></pre>
  
  <p>However I'm not sure if it's completely correct. Should I use a std::vector with my original comparison function and sort it with std::sort instead?
  Thanks for your answers. </p>