int[] addRegions(int[] regions, Set<Integer> regionIndicesToAdd) {
    int[] newRegions = new int[regions.length + regionIndicesToAdd.size()];

    // Copy the existing regions to the new array
    System.arraycopy(regions, 0, newRegions, 0, regions.length);

    // Add the new regions at the end of the array
    int newIndex = regions.length;
    for (int regionIndex : regionIndicesToAdd) {
      newRegions[newIndex++] = regionIndex;
    }

    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