int[] replaceRegion(int[] regions, int regionIndex, int newRegionIndex) {
    int i = 0;
    for (i = 0; i < regions.length; i++) {
      if (regions[i] == regionIndex) {
        regions[i] = newRegionIndex;
        break;
      }
    }
    return regions;
  }
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