You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a new extension method on jagged arrays (e.g. int[][]) to allow converting them to a multi-dimensional array of the same size (e.g. int[,]). Since the jagged array can have a different number of columns for each row, there should be two options:
Use the size of the smallest row.
Use the size of the largest row and provide a default value for the blank cells.
Add tests for the new extension.
Value Proposition
Most of the array extensions in this library use multi-dimensional arrays instead of jagged arrays. Adding this extension would allow easily converting a jagged array to a multi-dimensional array to take advantage of the other extensions this library provides or to serve as a backing array for a OneBasedArray.
Design Ideas
Will likely require two methods that will return a multi-dimension array of a different size based on the largest/smallest row in the jagged array
First step is to calculate the size of the output array. Either find the largest or the smallest row in the input jagged array and use that for the second dimension of the output array.
Will probably need to be implemented with two for-loops that iterate over the jagged array and build the new multi-dimensional array as they go.
If the cell is inside the bounds of the jagged array, copy over the value
If the cell is outside the bounds of the jagged array, use the provided default value
Possibly add a third method that takes maxColumn and maxRow variables that define the size of the output array. When creating the array, if there is no corresponding location in the jagged array, use the default value.
The text was updated successfully, but these errors were encountered:
Requirement
int[][]
) to allow converting them to a multi-dimensional array of the same size (e.g.int[,]
). Since the jagged array can have a different number of columns for each row, there should be two options:Value Proposition
Most of the array extensions in this library use multi-dimensional arrays instead of jagged arrays. Adding this extension would allow easily converting a jagged array to a multi-dimensional array to take advantage of the other extensions this library provides or to serve as a backing array for a
OneBasedArray
.Design Ideas
maxColumn
andmaxRow
variables that define the size of the output array. When creating the array, if there is no corresponding location in the jagged array, use the default value.The text was updated successfully, but these errors were encountered: