Caution should be exercised when using a comparator capable of imposing an ordering inconsistent with equals to order a sorted set (or sorted map). Suppose a sorted set (or sorted map) with an explicit Comparator c is used with elements (or keys) drawn from a set S. If the ordering imposed by c on S is inconsistent with equals, the sorted set (or sorted map) will behave "strangely." In particular the sorted set (or sorted map) will violate the general contract for set (or map), which is defined in terms of equals.
For example, if one adds two keys a and b such that (a.equals((Object)b) && c.compare((Object)a, (Object)b) != 0) to a sorted set with comparator c, the second add operation will return false (and the size of the sorted set will not increase) because a and b are equivalent from the sorted set's perspective.
SCJP, SCWCD, SCBCD
SCJP 6  SCWCD 5  Javaranch SCJP FAQ  SCWCD Links
SCJP, SCWCD, SCBCD
SCJP 6  SCWCD 5  Javaranch SCJP FAQ  SCWCD Links
SCJP, SCWCD, SCBCD
SCJP 6
SCJP, SCWCD, SCBCD
When evil is afoot and you don't have any arms you gotta be hip and do the legwork, but always kick some ... tiny ad:
Free, earth friendly heat  from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/freeheat
