int[] removeRegion(int[] regions, int regionIndex) {
    // TODO: this maybe costly. Consider using linked lists
    int[] newRegions = new int[regions.length - 1];
    int i = 0;
    for (i = 0; i < regions.length; i++) {
      if (regions[i] == regionIndex) {
        break;
      }
      newRegions[i] = regions[i];
    }
    System.arraycopy(regions, i + 1, newRegions, i, newRegions.length - i);
    return newRegions;
  }
Common method for per host and per Location region index updates when a region is moved.
@param serverIndexToLocation             serverIndexToHostIndex or serverIndexToLocationIndex
@param regionsPerLocation                regionsPerHost or regionsPerLocation
@param colocatedReplicaCountsPerLocation colocatedReplicaCountsPerHost or
                                         colocatedReplicaCountsPerRack
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerClusterState.java