Return a list of rows that contain the String passed in. If there are no matches, a zero length array will be returned (not a null array). @param regexp the String to match @param column ID number of the column to search
(String regexp, int column)
| 3882 | * @param column ID number of the column to search |
| 3883 | */ |
| 3884 | public int[] matchRowIndices(String regexp, int column) { |
| 3885 | int[] outgoing = new int[rowCount]; |
| 3886 | int count = 0; |
| 3887 | |
| 3888 | checkColumn(column); |
| 3889 | if (columnTypes[column] == STRING) { |
| 3890 | String[] stringData = (String[]) columns[column]; |
| 3891 | for (int row = 0; row < rowCount; row++) { |
| 3892 | if (stringData[row] != null && |
| 3893 | PApplet.match(stringData[row], regexp) != null) { |
| 3894 | outgoing[count++] = row; |
| 3895 | } |
| 3896 | } |
| 3897 | } else { // less efficient, includes conversion as necessary |
| 3898 | for (int row = 0; row < rowCount; row++) { |
| 3899 | String str = getString(row, column); |
| 3900 | if (str != null && |
| 3901 | PApplet.match(str, regexp) != null) { |
| 3902 | outgoing[count++] = row; |
| 3903 | } |
| 3904 | } |
| 3905 | } |
| 3906 | return PApplet.subset(outgoing, 0, count); |
| 3907 | } |
| 3908 | |
| 3909 | |
| 3910 | /** |
no test coverage detected