My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 151: Make the page overflow call non-recursive
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  jeff.johnston.mn@gmail.com
Closed:  Oct 2008


 
Project Member Reported by jeff.johnston.mn@gmail.com, Oct 3, 2008
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
Have this implemented.
Status: Fixed

Powered by Google Project Hosting