void (int position) { myStringBuilder.setLength(position); if (myLineToOffsetMapping != null) { Map<Integer, Integer> newMap = new HashMap<>(); for (Map.Entry<Integer, Integer> entry : myLineToOffsetMapping.entrySet()) { if (entry.getValue() <= position) { newMap.put(entry.getKey(), entry.getValue()); } } myLineToOffsetMapping = newMap; } }