CMatrix:Cols
The Cols method returns the maximum column index in any row of the CMatrix. This is the number of columns needed to hold every possible index in a completely filled (or "packed") matrix.
number = CMatrix:Cols() |
This method returns the maximum column index in any row of the matrix. Since all indices do not have to be filled in a sparse matrix, the returned value is not the same as the number of members defined in any row. Since the indices are 1-based, the maximum index is the same number as the maximum column index. For example, if the CMatrix has 1 row with two members, one at index [1][1] and the other at index [1][10000], then Cols = 10000.
Suppose a CMatrix assigned to M contains 3 members as shown below:
|
-- create a CMatrix |
|
-- set member 2, 44 |
|
-- set member 50, 20 |
|
-- set member 120, 2 |
|
-- result: Cols = 44 |
|
-- if finished with M, clean up memory |