ключей:
You are correct that keys should be Comparable - but that is not always required, it is good if they are (in case they have the same hashCode), but in case they are not, this is used:
static int tieBreakOrder(Object a, Object b) {
int d;
if (a == null | | b == null | |
(d = a.getClass().getName().
compareTo(b.getClass().getName())) == 0)
d = (System.identityHashCode(a) <= System.identityHashCode(b) ?
-1 : 1);
return d;
}
So the className as a String is used for comparison and if that fails too, then System.identityHashCode is used (Marsaglia XOR-Shift algorithm) to decide the left and right.
Чат не читай @ Закидывай баяны Это обсудили уже)
Сорри, не видел что раньше было
Обсуждают сегодня