So for homework, one of the things I've been tasked with is swapping 2 rows or 2 columns with each other with a matrix that's built in a class type object, using those 3 parameters to define it:

```
size_t _R;// Number of rows.
size_t _C;// Number of columns.
std::vector<T> mat;// array of T type variables to represent the matrix.

```

For example if I had 3 rows and 3 columns and the int vector array of 1,2,3,4,5,6,7,8,9, swapping rows 0 and 1 would make it look like 4,5,6,1,2,3,7,8,9.

So making the swap happen isn't the problem here, what I don't understand though is **how are you meant to make that happen with O(1) complexity?**

What I wanted to do is individually switch between every type in the row/column, but then that'd be O(n), right? Because it'd depend on the amount of items in each row/column.

EDIT:
Example code for what I tried:

```
void swap_rows(const size_t& r1, const size_t& r2) {
    for (size_t i = 0; i < _C; i++)
    {
        T temp = mat[i + (r1 * _C)];
        mat[i + (r1 * _C)] = mat[i + (r2 * _C)];
        mat[i + (r2 * _C)] = temp;
    }
}

```

But I believe that's O(n) complexity, therefore a no-go :p