Source:
<code>private static @NonNull Table<ITimeGraphEntry, @NonNull Pair<Long, Long>, List<ITimeEvent>> regroupOverlappingGaps(Map<? extends ITimeGraphEntry, List<ITimeEvent>> gapsMap) { Table<ITimeGraphEntry, @NonNull Pair<Long, Long>, List<ITimeEvent>> gapsTable = HashBasedTable.create(); PriorityQueue<ITimeEvent> queue = new PriorityQueue<>(TIME_EVENT_COMPARATOR); gapsMap.values().forEach(event -> queue.addAll(event)); Pair<Long, Long> previous = null; while(!queue.isEmpty()) { ITimeEvent event = Objects.requireNonNull(queue.poll()); ITimeGraphEntry entry = event.getEntry(); Pair<Long, Long> result = previous != null && event.getTime() < previous.getRight() && event.getTime() + event.getDuration() > previous.getLeft() ? previous : null; Map<ITimeGraphEntry, List<ITimeEvent>> column = new HashMap<>(); if (result != null) { Pair<Long, Long> merged = mergeInterval(result, event); column = gapsTable.column(result); if (!result.equals(merged)) { <START> gapsTable.columnKeySet().remove(result); <END> result = merged; for (Entry<ITimeGraphEntry, List<ITimeEvent>> row : column.entrySet()) { gapsTable.put(row.getKey(), result, row.getValue()); } } } else { result = Objects.requireNonNull(Pair.of(event.getTime(), event.getTime() + event.getDuration())); } previous = result; List<ITimeEvent> events = gapsTable.get(entry, result); if (events == null) { events = new ArrayList<>(); gapsTable.put(entry, result, events); } events.add(event); } return gapsTable; }</code><technical_language>remove this key (Pair) clears out data row in underlying table. try add List<ITimeEvent> a new row a new key (Pair), adds column.entrySet() is empty</technical_language>

Target:
private static @NonNull Table<ITimeGraphEntry, @NonNull Pair<Long, Long>, List<ITimeEvent>> regroupOverlappingGaps(Map<? extends ITimeGraphEntry, List<ITimeEvent>> gapsMap) { Table<ITimeGraphEntry, @NonNull Pair<Long, Long>, List<ITimeEvent>> gapsTable = HashBasedTable.create(); PriorityQueue<ITimeEvent> queue = new PriorityQueue<>(TIME_EVENT_COMPARATOR); gapsMap.values().forEach(events -> queue.addAll(events)); Pair<Long, Long> previous = null; while(!queue.isEmpty()) { ITimeEvent event = Objects.requireNonNull(queue.poll()); ITimeGraphEntry entry = event.getEntry(); Pair<Long, Long> result = previous != null && event.getTime() < previous.getRight() && event.getTime() + event.getDuration() > previous.getLeft() ? previous : null; if (result != null) { Pair<Long, Long> merged = mergeInterval(result, event); Map<ITimeGraphEntry, List<ITimeEvent>> currentColumn = gapsTable.column(result); Map<ITimeGraphEntry, List<ITimeEvent>> column = new HashMap<>(currentColumn); final int count[] = new int[]{0}; column.values().forEach(events -> { count[0] += events.size();}); if (!result.equals(merged)) { gapsTable.columnKeySet().remove(result); final int count2[] = new int[]{0}; column.values().forEach(events -> { count2[0] += events.size();}); result = merged; for (Entry<ITimeGraphEntry, List<ITimeEvent>> row : column.entrySet()) { gapsTable.put(row.getKey(), result, row.getValue()); } } } else { result = Objects.requireNonNull(Pair.of(event.getTime(), event.getTime() + event.getDuration())); } previous = result; List<ITimeEvent> events = gapsTable.get(entry, result); if (events == null) { events = new ArrayList<>(); gapsTable.put(entry, result, events); } events.add(event); } return gapsTable; }