title: Using a (mathematical) vector in a std::map
body: <p>Related: <a href="https://stackoverflow.com/questions/1856597/what-can-i-use-as-stdmap-keys">what can I use as <code>std::map</code> keys?</a></p>
  
  <p>I needed to create a mapping where specific key locations in space map to lists of objects.  <code>std::map</code> seemed the way to do it.</p>
  
  <p>So I'm keying a <code>std::map</code> on an xyz <code>Vector</code></p>
  
  <pre><code>class Vector
  { 
    float x,y,z
  } ;
  </code></pre>
  
  <p>, and I'm making a <code>std::map&lt;Vector, std::vector&lt;Object*&gt; &gt;</code>.  So note the key here <strong>is not</strong> a <code>std::vector</code>, its an object of <code>class Vector</code> which is just a math xyz vector of my own making.</p>
  
  <p>To produce a "strictly weak ordering" I've written the following overload for <code>operator&lt;</code>:</p>
  
  <pre><code>  bool Vector::operator&lt;( const Vector &amp; b ) const {
      // z trumps, then y, then x
      if( z &lt; b.z )
      {
        return true ;
      }
      else if( z == b.z )
      {
        if( y &lt; b.y )
        {
          // z == b.z and y &lt; b.y
          return true ;
        }
        else if( y == b.y )
        {
          if( x &lt; b.x )
          {
            return true ;
          }
          else if( x == b.x )
          {
            // completely equal
            return false ;
          }
          else
          {
            return false ;
          }
        }
        else
        {
          // z==b.z and y &gt;= b.y
          return false ;
        }
      }
      else
      {
        // z &gt;= b.z
        return false ;
      }
    }
  </code></pre>
  
  <p>Its a bit long but basically makes it so any vector can consistently be said to be less than any other vector ((-1, -1, -1) &lt; (-1,-1,1), and (-1, -1, 1) > (-1,-1,-1) for example).</p>
  
  <p>My problem is this is really artificial and although I've coded it and it works, I am finding that it "pollutes" my Vector class (mathematically) with this really weird, artificial, non-math-based notion of "less than" for a vector.</p>
  
  <p>But I need to create a mapping where specific key locations in space map to certain objects, and std::map seems the way to do it.</p>
  
  <p>Suggestions?  Out-of-box solutions welcome!!</p>