static L lineComp_replacePairWithUpdatingPairCount(IContentsIndexedList2 l, Int pa, Int pb, Int y, LineComp_PairCounts pairCounts) { int i = 0; while (true) { i = indexOfIntPairInContentsIndexedList(l, pa, pb, i); if (i < 0) break; int to = i+2, to_new = i+1; pairCounts.removeAll(overlappingIntPairs(subList(l, i-1, to+1))); l.set(i, y); l.remove(i+1); pairCounts.addAll(overlappingIntPairs(subList(l, i-1, to_new+1))); i = to_new; } ret l; }