public void add ( int [ ] itemset ) { numTransactions ++ ; int m = 0 ; int t = itemset . length ; int [ ] o = new int [ t ] ; for ( int i = 0 ; i < t ; i ++ ) { int item = itemset [ i ] ; o [ i ] = order [ item ] ; if ( itemSupport [ item ] >= minSupport ) { m ++ ; } } if ( m > 0 ) { // Order all items in itemset in frequency descending order // Note that some items may have same frequency. We have to make // sure that items are in the same order of header table. QuickSort . sort ( o , itemset , t ) ; // Note that itemset may contain duplicated items. We should keep // only one in case of getting incorrect support value. for ( int i = 1 ; i < m ; i ++ ) { if ( itemset [ i ] == itemset [ i - 1 ] ) { m -- ; for ( int j = i ; j < m ; j ++ ) { itemset [ j ] = itemset [ j + 1 ] ; } } } root . add ( 0 , m , itemset , 1 ) ; } }
Add an item set into the FP - tree .