| Issue 151: | Make the page overflow call non-recursive | |
| 1 person starred this issue and may be notified of changes. | Back to list |
The current implementation of getValidPage is recursive:
private int getValidPage(int page, int maxRows, int totalRows) {
if (!isValidPage(page, maxRows, totalRows)) {
return getValidPage(--page, maxRows, totalRows);
}
return page;
}
Im trying to implement a table that allows the user to type in the
row they want and go there directly (happy to contribute back, if
anyone wants it). Unfortunately, the problem with the recursive
implementation is that I get stack overflows quite quickly. Would a
non-recursive implementation be a problem?
**********************************************************************
Sure, it just runs me out of memory if I select a high enough number.
This, on the other hand, doesn't:
private int getValidPage(int page, int maxRows, int totalRows) {
while (!isValidPage(page, maxRows, totalRows)) {
--page;
}
return page;
}
Oct 25, 2008
Project Member
#1
jeff.johnston.mn@gmail.com
Status:
Fixed
|