title: Which sorted STL container to use for fast insert and find with a special key?
body: <p>I have some data with a key associated with each data item. The key is made of two parts: let's call them color and id. I want to iterate the container by color to speed up rendering and I also want to find items in the container by id alone.</p>
  
  <p>I tried using std::map for this with a key</p>
  
  <pre><code>class MyKey {
  public:
    int color;
    int id;
    bool operator&lt;(...)
    bool operator==(...)
  };
  </code></pre>
  
  <p>But I cannot provide a &lt; operator that would keep the data sorted by color and at the same time allow map::find to work on id alone (i.e. no information about color).</p>
  
  <p>I want both the insert and find operations to be fast (e.g. O(log(n))).</p>
  
  <p>Any ideas what kind of container I could use to implement this?</p>