GeometryClassLibrary.MatricesMatrix.GetColumnWidth C# (CSharp) Method

GetColumnWidth() public method

Returns the number of columns of the matrix with the largest number of columns in the specified column of the MatricesMatrix
public GetColumnWidth ( int col ) : int
col int
return int
        public int GetColumnWidth(int col)
        {
            int maxSeen = 0;
            
            for (int row = 0; row < this.NumberOfRows; row++)
            {
                if (this.GetElement(row, col).NumberOfColumns > maxSeen)
                {
                    maxSeen = this.GetElement(row, col).NumberOfColumns;
                }
            }

            return maxSeen;
        }

Usage Example

コード例 #1
0
        public void MatricesMatrix_GetColumnWidthTest()
        {
            Matrix m1 = new Matrix(1);
            Matrix m2 = new Matrix(2);
            Matrix m3 = new Matrix(3);
            Matrix m4 = new Matrix(4);

            MatricesMatrix testMatricesMatrix = new MatricesMatrix(2, 2);

            testMatricesMatrix.SetElement(0, 0, m1);
            testMatricesMatrix.SetElement(0, 1, m3);
            testMatricesMatrix.SetElement(1, 0, m2);
            testMatricesMatrix.SetElement(1, 1, m4);

            int expectedResult1 = 2;
            int expectedResult2 = 4;

            int actualResult1 = testMatricesMatrix.GetColumnWidth(0);
            int actualResult2 = testMatricesMatrix.GetColumnWidth(1);

            (actualResult1 == expectedResult1).Should().BeTrue();
            (actualResult2 == expectedResult2).Should().BeTrue();


        }