question: private static void adjustMappingPairVector ( int col , int incr , Vector < MappingPair > vec ) { int i ; for ( i = 0 ; ( i < vec . size ( ) ) && ( vec . elementAt ( i ) . col < col ) ; i ++ ) { } if ( i == vec . size ( ) ) { vec . add ( new MappingPair ( col , incr ) ) ; } else if ( vec . elementAt ( i ) . col == col ) { vec . elementAt ( i ) . inc = vec . elementAt ( i ) . inc + incr ; } else { vec . insertElementAt ( new MappingPair ( col , incr ) , i ) ; } }
target:  Modify vec so the line mapping nl it represents is related to the original line mapping ol by nl[c] = IF c < col THEN ol[c] ELSE ol[c] + incr.  In other words, if adding n characters (or removing -incr  characters) before the character in column c, then call adjustMappingPairVector(c, n, ...).  However, if replacing  a token of length blen at column c by an expression of length nlen, then call adjustMappingPairVector(c+1, nlen - olen, ...) because: (a) the beginning position of the expression is the same as that of the token, and (b) one should never be looking at or modifying anything inside the expression, so we can call adjustMappingPairVector with any first argument between c+1 and c+(length of original token).