private int[] calculateTaskCountPerContainer(int taskCount,int prevContainerCount,int currentContainerCount){
  int[] newTaskCountPerContainer=new int[Math.max(currentContainerCount,prevContainerCount)];
  Arrays.fill(newTaskCountPerContainer,0);
  for (int i=0; i < currentContainerCount; i++) {
    newTaskCountPerContainer[i]=taskCount / currentContainerCount;
    if (taskCount % currentContainerCount > i) {
      newTaskCountPerContainer[i]++;
    }
  }
  return newTaskCountPerContainer;
}

private int [ ] calculateTaskCountPerContainer ( int taskCount , int prevContainerCount , int currentContainerCount ) { int [ ] newTaskCountPerContainer = new int [ Math . max ( currentContainerCount , prevContainerCount ) ] ; Arrays . fill ( newTaskCountPerContainer , 0 ) ; for ( int i = 0 ; i < currentContainerCount ; i ++ ) { newTaskCountPerContainer [ i ] = taskCount / currentContainerCount ; if ( taskCount % currentContainerCount > i ) { newTaskCountPerContainer [ i ] ++ ; } } return newTaskCountPerContainer ; }
calculates the expected number of tasks for each container . the count is generated for max ( oldcontainercount , newcontainercount ) s . t . if the container count has decreased , the excess containers will have a count = = 0 , indicating that any tasks assigned to them should be reassigned .
