public static int[] toAdjustedColumnArray(int[] colarr, int colindex,
            int adjust) {

        if (colarr == null) {
            return null;
        }

        if (colindex < 0) {
            return colarr;
        }

        int[] intarr = new int[colarr.length];
        int   j      = 0;

        for (int i = 0; i < colarr.length; i++) {
            if (colarr[i] > colindex) {
                intarr[j] = colarr[i] + adjust;

                j++;
            } else if (colarr[i] == colindex) {
                if (adjust < 0) {

                    // skip an element from colarr
                } else {
                    intarr[j] = colarr[i] + adjust;

                    j++;
                }
            } else {
                intarr[j] = colarr[i];

                j++;
            }
        }

        if (colarr.length != j) {
            int[] newarr = new int[j];

            copyArray(intarr, newarr, j);

            return newarr;
        }

        return intarr;
    }
public static int [ ] toAdjustedColumnArray ( int [ ] colarr , int colindex , int adjust ) { if ( colarr == null ) { return null ; } if ( colindex < 0 ) { return colarr ; } int [ ] intarr = new int [ colarr . length ] ; int j = 0 ; for ( int i = 0 ; i < colarr . length ; i ++ ) { if ( colarr [ i ] > colindex ) { intarr [ j ] = colarr [ i ] + adjust ; j ++ ; } else if ( colarr [ i ] == colindex ) { if ( adjust < 0 ) { } else { intarr [ j ] = colarr [ i ] + adjust ; j ++ ; } } else { intarr [ j ] = colarr [ i ] ; j ++ ; } } if ( colarr . length != j ) { int [ ] newarr = new int [ j ] ; copyArray ( intarr , newarr , j ) ; return newarr ; } return intarr ; }
Returns a new array with the elements in collar adjusted to reflect
changes at colindex. <p>

Each element in collarr represents an index into another array
otherarr. <p>

colindex is the index at which an element is added or removed.
Each element in the result array represents the new,
adjusted index. <p>

For each element of collarr that represents an index equal to
colindex and adjust is -1, the result will not contain that element
and will be shorter than collar by one element.

@param  colarr the source array
@param  colindex index at which to perform adjustement
@param  adjust +1, 0 or -1
@return new, adjusted array