Tushar Goel wrote:I dont think you can do this way. Probably you need store them in some collection and each time you are adding any element into it,
you need to compare that with all the values present the map.
Paweł Baczyński wrote:Your new comparator can never return a negative value.
So it violates this rule:
The implementor must ensure that sgn(compare(x, y)) == -sgn(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)
What do you mean by repeated node? A node with the same coordinates as some other node?
Stephan van Hulst wrote:If the key of the map is unrelated to the id of the unit, then you can't do this with your map. You should use different keys, or sort your values at a later stage.