Int2IntMap (Diff.Change change, int firstNLines) { Int2IntMap result = new Int2IntOpenHashMap(); int prevLineInFirst = 0; int prevLineInSecond = 0; while (change != null) { for (int l = 0; l < change.line0 - prevLineInFirst; l++) { result.put(prevLineInFirst + l, prevLineInSecond + l); } prevLineInFirst = change.line0 + change.deleted; prevLineInSecond = change.line1 + change.inserted; change = change.link; } for (int i = prevLineInFirst; i < firstNLines; i++) { result.put(i, prevLineInSecond + i - prevLineInFirst); } return result; }