lullaby/modules/layout/layout.cc
// Computes the number of groups needed when a |total_count| of elements is
// divided into |count_per_group| elements.
Computes the number of groups needed when a |total_count| of elements is
divided into |count_per_group| elements.
Computes the number of groups needed when a |total_count| of elements is divided into |count_per_group| elements .
size_t CalculateNumberOfGroups(size_t total_count, size_t count_per_group) {
  if (count_per_group == 0) {
    return total_count;
  }
  const size_t rounded_toward_zero = total_count / count_per_group;
  const size_t intermediate_product = rounded_toward_zero * count_per_group;
  if (intermediate_product < total_count) {
    return rounded_toward_zero + 1;
  } else {
    return rounded_toward_zero;
  }
}
size_t CalculateNumberOfGroups ( size_t total_count , size_t count_per_group ) { if ( count_per_group == 0 ) { return total_count ; } const size_t rounded_toward_zero = total_count / count_per_group ; const size_t intermediate_product = rounded_toward_zero * count_per_group ; if ( intermediate_product < total_count ) { return rounded_toward_zero + 1 ; } else { return rounded_toward_zero ; } }
Computes the number of groups needed when a |total_count| of elements is
divided into |count_per_group| elements.
Computes the number of groups needed when a |total_count| of elements is divided into |count_per_group| elements .