private boolean putInList ( Entry entry ) { FilterCellFastStr currentCell = firstCell ; FilterCellFastStr nextCell = null ; int [ ] hashcodes = entry . getHashcodes ( ) ; int [ ] lengths = entry . getLengths ( ) ; // work from back to front int lastIndex = entry . getCurrentSize ( ) - 1 ; for ( int i = lastIndex ; i >= 0 ; i -- ) { // test for wildcard if ( ( hashcodes [ i ] == 0 ) && ( lengths [ i ] == 0 ) ) { currentCell . addNewCell ( hashcodes [ i ] , lengths [ i ] ) ; return true ; } // check in nextCell has different lengths, if so, then // we can't use this "fast" method nextCell = currentCell . findNextCell ( hashcodes [ i ] ) ; if ( nextCell != null ) { if ( nextCell . getHashLength ( ) != lengths [ i ] ) { return false ; } } if ( nextCell == null ) { // new address, complete the tree for ( int j = i ; j >= 0 ; j -- ) { currentCell = currentCell . addNewCell ( hashcodes [ j ] , lengths [ j ] ) ; if ( ( hashcodes [ j ] == 0 ) && ( lengths [ j ] == 0 ) ) { // nothing can come before a wildcard, so return return true ; } } return true ; } currentCell = nextCell ; } return true ; }
Add and new address to the address tree where the new address is represented by an Entry object .