in tools/javac/ApiComparator.java [300:329]
private static <T> Node compare(Map<T, T> a, Map<T, T> b, BiFunction<T, T, Node> comparator, Node next) {
Node node = next;
if (a == null) {
for (T bt : b.values()) {
Node n = comparator.apply(null, bt);
n.next = node;
node = n;
}
} else if (b == null) {
for (T at : a.values()) {
Node n = comparator.apply(at, null);
n.next = node;
node = n;
}
} else {
Map<T, T> aTypes = new HashMap<>(a);
for (T bt : b.values()) {
T at = aTypes.remove(bt);
Node n = comparator.apply(at, bt);
n.next = node;
node = n;
}
for (T at : aTypes.values()) {
Node n = comparator.apply(at, null);
n.next = node;
node = n;
}
}
return node;
}