title: Map which allows to provide the equals-comparator and the hashing function separately
body: <p>While trying to model polynomials, in particular their multiplication, I run into the following problem. During the multiplication, the individual monomials of the two polynomials are multiplied and of course in can happen that I have (3x^2 y + 5x y^2) * (x + y). The result contains 3x^2 y^2  and 5 x^2 y^2, which I want to combine by addition right away. </p>
  
  <p>Naturally I would like to use the part x^2 y^2 of the monomial as a key in a (hash) map to add up the different coefficients (3 and 5 in the example). But the monomial object as I envisage it should naturally also contain the coefficient, which should <strong>not</strong> be part of the map key. </p>
  
  <p>Of course I could write equals/hashcode of the monomial object such that they ignore the coefficient. But this feels just so wrong, because mathematically a monomial clearly is only equal to another one if also the coefficients are equal.</p>
  
  <p>Introducing a coefficient-free monomial object for intermediate operations does also not look right.</p>
  
  <p>Instead of using the map, I could use a list and use a binary search with a dedicated comparator that ignores the coefficient.</p>
  
  <p>Short of implementing a map which does not use the keys' equals/hashcode, but a dedicated one, are there any better ideas of how to fuse the monomials?</p>