lullaby/modules/layout/layout.cc
// outer_idx is the index in the secondary direction
// outer_count is the count of primary rows in secondary direction
// elements_per_wrap is the length of the primary rows
// total_size is the count of all the elements
outer_idx is the index in the secondary direction
outer_count is the count of primary rows in secondary direction
elements_per_wrap is the length of the primary rows
total_size is the count of all the elements
outer_idx is the index in the secondary direction outer_count is the count of primary rows in secondary direction elements_per_wrap is the length of the primary rows total_size is the count of all the elements
InnerIndexRange(LayoutFillOrder fill_order_, size_t outer_idx,
                  size_t outer_count, size_t elements_per_wrap,
                  size_t total_size)
      : fill_order(fill_order_) {
    size_t index;
    if (IsOuterForward()) {
      index = outer_idx;
    } else if (IsOuterBackward()) {
      index = ReverseIndex(outer_idx, outer_count);
    } else {
      LOG(DFATAL) << "Invalid fill order: " << fill_order;
      return;
    }
    start = index * elements_per_wrap;
    size = std::min((index + 1) * elements_per_wrap, total_size) - start;
  }
InnerIndexRange ( LayoutFillOrder fill_order_ , size_t outer_idx , size_t outer_count , size_t elements_per_wrap , size_t total_size ) : fill_order ( fill_order_ ) { size_t index ; if ( IsOuterForward ( ) ) { index = outer_idx ; } else if ( IsOuterBackward ( ) ) { index = ReverseIndex ( outer_idx , outer_count ) ; } else { LOG ( DFATAL ) << " " << fill_order ; return ; } start = index * elements_per_wrap ; size = std :: min ( ( index + 1 ) * elements_per_wrap , total_size ) - start ; }
outer_idx is the index in the secondary direction
outer_count is the count of primary rows in secondary direction
elements_per_wrap is the length of the primary rows
total_size is the count of all the elements
outer_idx is the index in the secondary direction outer_count is the count of primary rows in secondary direction elements_per_wrap is the length of the primary rows total_size is the count of all the elements
// Make sure the last index doesn't exceed the total_size.