It is also possible to traverse just one dimension of a multidimensional set of data. Say we just want to print out the third row of a table of data. This only requires traversing in one dimension - side to side through a single row. The list of elements we need to visit looks like:
The row of everything we are trying to access is 2. This means we can use a set value for the row index. Which means we do not need a loop that iterates through the various rows. Instead, we will have a single loop that traverses the columns of that row. The code looks like this:
Note that even though we are only using a single loop to traverse one dimension, we still have to specify both a row and column to access a single int value in the table.
To get the number of columns in a particular row, use gridName.at(rowIndex).size(). If all the rows have the same number of columns, you can use gridName.at(0).size().