It's correct for sets, which just consist of keys, but with maps it's only comparing key values which is definitely wrong. If it's going to be exposed on maps too, it should do what C++ does and treat the map as [(T, U)].