Data (@NotNull final Iterator<int[]> changedLines) { int[] starts = new int[myCount]; int[] ends = new int[myCount]; int[] last = new int[myCount]; for (int i = 0; i < myCount; i++) { last[i] = Integer.MIN_VALUE; } while (changedLines.hasNext()) { int[] offsets = changedLines.next(); for (int i = 0; i < myCount; i++) { starts[i] = last[i]; ends[i] = offsets[i * 2]; last[i] = offsets[i * 2 + 1]; } addGroup(starts, ends); } for (int i = 0; i < myCount; i++) { starts[i] = last[i]; ends[i] = Integer.MAX_VALUE; } addGroup(starts, ends); return new Data(myGroups, (project, line, index) -> getDescription(project, line, index)); }