MyMediaLite.DataType.SparseBooleanMatrix.RemoveColumn C# (CSharp) Method

RemoveColumn() public method

Removes a column, and fills the gap by decrementing all occurrences of higher column IDs by one
public RemoveColumn ( int y ) : void
y int the column ID
return void
        public void RemoveColumn(int y)
        {
            for (int row_id = 0; row_id < row_list.Count; row_id++)
            {
                var cols = new List<int>(row_list[row_id]);
                foreach (int col_id in cols)
                {
                    if (col_id >= y)
                        row_list[row_id].Remove(y);
                    if (col_id > y)
                        row_list[row_id].Add(col_id - 1);
                }
            }
        }

Usage Example

        public void TestRemoveColumns()
        {
            var matrix = new SparseBooleanMatrix();
            for (int i = 0; i < 7; i++)
                if(i != 2 && i != 4)
                {
                    matrix[i, 1]= true;
                    matrix[i, 4]= true;
                }
            matrix[2, 2] = true;
            matrix[2, 5] = true;
            matrix[4, 3] = true;
            int[] delete_columns = {2, 4};
            matrix.RemoveColumn(delete_columns);

            // test the new columns
            Assert.IsTrue(matrix[4, 2]);
            Assert.IsTrue(matrix[2, 3]);
            Assert.IsFalse(matrix[1, 3]);
            Assert.IsFalse(matrix[4, 3]);
        }
All Usage Examples Of MyMediaLite.DataType.SparseBooleanMatrix::RemoveColumn