private static void adjustGroupIndices ( int [ ] [ ] allGroupIndices , int modifiedIndex , boolean remove ) { final int offset = remove ? - 1 : + 1 ; for ( int [ ] allGroupIndice : allGroupIndices ) { int [ ] groupIndices = allGroupIndice ; for ( int i = 0 ; i < groupIndices . length ; i ++ ) { int index = groupIndices [ i ] ; if ( index == modifiedIndex && remove ) { throw new IllegalStateException ( "The removed index " + modifiedIndex + " must not be grouped." ) ; } else if ( index >= modifiedIndex ) { groupIndices [ i ] += offset ; } } } }
Adjusts group indices . Shifts the given groups to left right up down according to the specified remove or add flag .