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.

Syntax

number = CMatrix:Cols()

bullet.gif    On success, this method returns the maximum column index in any row.

bullet.gif    On failure, this method returns 0.

Remarks

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.

Example

Suppose a CMatrix assigned to M contains 3 members as shown below:

M = new_matrix()

-- create a CMatrix

M:Set( 2, 44, 1805 )

-- set member 2, 44

M:Set( 50, 20, 102 )

-- set member 50, 20

M:Set( 120, 2, 600.5 )

-- set member 120, 2

Printf("Cols = %d", M:Cols())

-- result: Cols = 44

M:delete()

-- if finished with M, clean up memory

Related Topics

CMatrix class, Exists


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.