Skip to content

Commit 4d9c313

Browse files
committed
fix for Iterable vs Iterator for Table
1 parent 453a34e commit 4d9c313

File tree

1 file changed

+42
-8
lines changed

1 file changed

+42
-8
lines changed

core/src/processing/data/Table.java

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,7 @@ public TableRow getRow(int row) {
20282028
* Note that this one iterator instance is shared by any calls to iterate
20292029
* the rows of this table. This is very efficient, but not thread-safe.
20302030
* If you want to iterate in a multi-threaded manner, don't use the iterator.
2031-
*
2031+
*
20322032
* @webref table:method
20332033
* @brief Gets multiple rows from a table
20342034
*/
@@ -2981,28 +2981,45 @@ public TableRow findRow(String value, int column) {
29812981
return (row == -1) ? null : new RowPointer(this, row);
29822982
}
29832983

2984+
29842985
/**
29852986
* @param columnName title of the column to search
29862987
*/
29872988
public TableRow findRow(String value, String columnName) {
29882989
return findRow(value, getColumnIndex(columnName));
29892990
}
29902991

2992+
2993+
public Iterable<TableRow> findRows(final String value, final int column) {
2994+
return new Iterable<TableRow>() {
2995+
public Iterator<TableRow> iterator() {
2996+
return findRowIterator(value, column);
2997+
}
2998+
};
2999+
}
3000+
3001+
3002+
public Iterable<TableRow> findRows(final String value, final String columnName) {
3003+
return findRows(value, getColumnIndex(columnName));
3004+
}
3005+
3006+
29913007
/**
29923008
* @webref table:method
29933009
* @brief Finds multiple rows that contain the given value
29943010
* @param value the value to match
29953011
* @param column ID number of the column to search
29963012
*/
2997-
public Iterator<TableRow> findRows(String value, int column) {
3013+
public Iterator<TableRow> findRowIterator(String value, int column) {
29983014
return new RowIndexIterator(this, findRowIndices(value, column));
29993015
}
30003016

3017+
30013018
/**
30023019
* @param columnName title of the column to search
30033020
*/
3004-
public Iterator<TableRow> findRows(String value, String columnName) {
3005-
return findRows(value, getColumnIndex(columnName));
3021+
public Iterator<TableRow> findRowIterator(String value, String columnName) {
3022+
return findRowIterator(value, getColumnIndex(columnName));
30063023
}
30073024

30083025

@@ -3103,28 +3120,45 @@ public TableRow matchRow(String regexp, int column) {
31033120
return (row == -1) ? null : new RowPointer(this, row);
31043121
}
31053122

3123+
31063124
/**
31073125
* @param columnName title of the column to search
31083126
*/
31093127
public TableRow matchRow(String regexp, String columnName) {
31103128
return matchRow(regexp, getColumnIndex(columnName));
31113129
}
31123130

3131+
3132+
public Iterable<TableRow> matchRows(final String value, final int column) {
3133+
return new Iterable<TableRow>() {
3134+
public Iterator<TableRow> iterator() {
3135+
return matchRowIterator(value, column);
3136+
}
3137+
};
3138+
}
3139+
3140+
3141+
public Iterable<TableRow> matchRows(String value, String columnName) {
3142+
return matchRows(value, getColumnIndex(columnName));
3143+
}
3144+
3145+
31133146
/**
31143147
* @webref table:method
31153148
* @brief Finds multiple rows that match the given expression
31163149
* @param value the regular expression to match
31173150
* @param column ID number of the column to search
31183151
*/
3119-
public Iterator<TableRow> matchRows(String value, int column) {
3152+
public Iterator<TableRow> matchRowIterator(String value, int column) {
31203153
return new RowIndexIterator(this, matchRowIndices(value, column));
31213154
}
31223155

3156+
31233157
/**
31243158
* @param columnName title of the column to search
31253159
*/
3126-
public Iterator<TableRow> matchRows(String value, String columnName) {
3127-
return matchRows(value, getColumnIndex(columnName));
3160+
public Iterator<TableRow> matchRowIterator(String value, String columnName) {
3161+
return matchRowIterator(value, getColumnIndex(columnName));
31283162
}
31293163

31303164

@@ -3203,7 +3237,7 @@ public void replaceAll(String regex, String replacement, String columnName) {
32033237

32043238
/**
32053239
* Remove any of the specified characters from the entire table.
3206-
*
3240+
*
32073241
* @webref table:method
32083242
* @brief Removes characters from the table
32093243
* @param tokens a list of individual characters to be removed

0 commit comments

Comments
 (0)