private boolean findInList ( int [ ] address , int index , FilterCell cell , int endIndex ) { if ( cell . getWildcardCell ( ) != null ) { // first look at wildcard slot if ( index == endIndex ) { // at the end, so we found a match, unwind returning true return true ; } // go to next level of this tree path FilterCell newcell = cell . getWildcardCell ( ) ; // recursively search this path if ( findInList ( address , index + 1 , newcell , endIndex ) ) { return true ; } // the wildcard path didn't work, so see if there is a non-wildcard path FilterCell nextCell = cell . findNextCell ( address [ index ] ) ; if ( nextCell != null ) { // see if we are at the end of a valid path if ( index == endIndex ) { // this path found a match, unwind returning true return true ; } // ok so far, recursively search this path return findInList ( address , index + 1 , nextCell , endIndex ) ; } // this path did not find a match. return false ; } // no wildcard here, try the non-wildcard path FilterCell nextCell = cell . findNextCell ( address [ index ] ) ; if ( nextCell != null ) { if ( index == endIndex ) { // this path found a match, unwind returning true return true ; } // ok so far, recursively search this path return findInList ( address , index + 1 , nextCell , endIndex ) ; } // this path did not find a match. return false ; }
Determine recursively if an address represented by an integer array is in the address tree