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)
| 3804 | * @param column ID number of the column to search |
| 3805 | */ |
| 3806 | public int[] matchRowIndices(String regexp, int column) { |
| 3807 | int[] outgoing = new int[rowCount]; |
| 3808 | int count = 0; |
| 3809 | |
| 3810 | checkColumn(column); |
| 3811 | if (columnTypes[column] == STRING) { |
| 3812 | String[] stringData = (String[]) columns[column]; |
| 3813 | for (int row = 0; row < rowCount; row++) { |
| 3814 | if (stringData[row] != null && |
| 3815 | PApplet.match(stringData[row], regexp) != null) { |
| 3816 | outgoing[count++] = row; |
| 3817 | } |
| 3818 | } |
| 3819 | } else { // less efficient, includes conversion as necessary |
| 3820 | for (int row = 0; row < rowCount; row++) { |
| 3821 | String str = getString(row, column); |
| 3822 | if (str != null && |
| 3823 | PApplet.match(str, regexp) != null) { |
| 3824 | outgoing[count++] = row; |
| 3825 | } |
| 3826 | } |
| 3827 | } |
| 3828 | return PApplet.subset(outgoing, 0, count); |
| 3829 | } |
| 3830 | |
| 3831 | |
| 3832 | /** |
no test coverage detected