private FPTree buildFPTree ( final Relation < BitVector > relation , int [ ] iidx , final int items ) { FPTree tree = new FPTree ( items ) ; FiniteProgress prog = LOG . isVerbose ( ) ? new FiniteProgress ( "Building FP-tree" , relation . size ( ) , LOG ) : null ; int [ ] buf = new int [ items ] ; for ( DBIDIter iditer = relation . iterDBIDs ( ) ; iditer . valid ( ) ; iditer . advance ( ) ) { // Convert item to index representation: int l = 0 ; SparseFeatureVector < ? > bv = relation . get ( iditer ) ; for ( int it = bv . iter ( ) ; bv . iterValid ( it ) ; it = bv . iterAdvance ( it ) ) { int i = iidx [ bv . iterDim ( it ) ] ; if ( i < 0 ) { continue ; // Skip non-frequent items } buf [ l ++ ] = i ; } // Skip too short entries if ( l >= minlength ) { Arrays . sort ( buf , 0 , l ) ; // Sort ascending tree . insert ( buf , 0 , l , 1 ) ; } LOG . incrementProcessed ( prog ) ; } LOG . ensureCompleted ( prog ) ; return tree ; }
Build the actual FP - tree structure .