private int prepare ( IAtom atom , IBond prev ) { int count = 0 ; amap [ atom . getIndex ( ) ] = 1 ; for ( IBond bond : atom . bonds ( ) ) { if ( bond == prev ) continue ; IAtom nbr = bond . getOther ( atom ) ; if ( amap [ nbr . getIndex ( ) ] == 0 ) { qbonds [ numBonds ++ ] = ( IQueryBond ) bond ; count += prepare ( nbr , bond ) + 1 ; } else if ( nbr . getIndex ( ) < atom . getIndex ( ) ) { ++ count ; // ring closure qbonds [ numBonds ++ ] = ( IQueryBond ) bond ; } } return count ; }
prepare the query the required stack size is returned