There is a matrix in the form of a two-dimensional array. There are numbers and strings in each row of the matrix. How do I remove the same rows? The same row indicates that the values at all latitudes are the same.
The solution I came up with is as follows:
Concatenate the values of each row into a string and use the index of the row vector as the key. The time complexity should be O (n ). Traverse hashtable to obtain the corresponding index, that is, the number of the remaining rows after repeated entries.
Is there a better solution to the matrix of pure numbers?
Supplement: Find a new solution using the dataview method:
- // Remove the dataview of the duplicate row
- Dataview mydataview = new dataview (datatable );
- String [] strcomuns = {"datacolumn", "datatype "};
- Dg2.datasource = mydataview. totable (true, strcomuns );
Datacolumn and ype are data column names in the datatable. The first parameter of the totable method specifies whether to remove duplicate rows, and the second parameter specifies which columns are used to determine whether duplicate rows exist.