DecompIterator decomposeIterator ( double from , double to , MolecularFormulaRange boundaries ) { init ( ) ; if ( to < 0d || from < 0d ) throw new IllegalArgumentException ( "Expect positive mass for decomposition: [" + from + ", " + to + "]" ) ; if ( to < from ) throw new IllegalArgumentException ( "Negative range given: [" + from + ", " + to + "]" ) ; final int [ ] minValues = new int [ weights . size ( ) ] ; final int [ ] boundsarray = new int [ weights . size ( ) ] ; double cfrom = from , cto = to ; Arrays . fill ( boundsarray , Integer . MAX_VALUE ) ; if ( boundaries != null ) { for ( int i = 0 ; i < boundsarray . length ; i ++ ) { IIsotope el = weights . get ( i ) . getOwner ( ) ; int max = boundaries . getIsotopeCountMax ( el ) ; int min = boundaries . getIsotopeCountMin ( el ) ; if ( min >= 0 || max >= 0 ) { boundsarray [ i ] = max - min ; minValues [ i ] = min ; if ( minValues [ i ] > 0 ) { final double reduceWeightBy = weights . get ( i ) . getMass ( ) * min ; cfrom -= reduceWeightBy ; cto -= reduceWeightBy ; } } } } final int [ ] minmax = new int [ 2 ] ; integerBound ( cfrom , cto , minmax ) ; final int deviation = minmax [ 1 ] - minmax [ 0 ] ; //calculate the required ERTs if ( ( 1 << ( ERTs . length - 1 ) ) <= deviation ) { calcERT ( deviation ) ; } final int [ ] [ ] [ ] ERTs = this . ERTs ; //take ERT with required deviation int [ ] [ ] currentERT ; if ( deviation == 0 ) currentERT = ERTs [ 0 ] ; else currentERT = ERTs [ 32 - Integer . numberOfLeadingZeros ( deviation ) ] ; return new DecompIterator ( currentERT , minmax [ 0 ] , minmax [ 1 ] , from , to , minValues , boundsarray , weights ) ; }
Returns an iterator over all decompositons of this mass range