private void extract(int minsupp,int minlength,int maxlength,int item,int[] postfix,int plen,int[] buf2,int[] buf3,boolean destruct,Collector col){
  if (header[item] == null) {
    return;
  }
  if (header[item].sibling == null) {
    if (header[item].count < minsupp) {
      return;
    }
    extractLinear(header[item].count,minsupp,minlength,maxlength,item,postfix,plen,buf2,col);
    if (destruct) {
      Arrays.fill(header,null);
    }
    return;
  }
  int support=0;
  for (FPNode cur=header[item]; cur != null; cur=cur.sibling) {
    support+=cur.count;
  }
  if (support < minsupp) {
    return;
  }
  Arrays.fill(buf3,0);
  for (FPNode cur=header[item]; cur != null; cur=cur.sibling) {
    for (FPNode parent=cur.parent; parent.key >= 0; parent=parent.parent) {
      buf3[parent.key]+=cur.count;
    }
  }
  final int mminlength=minlength - (plen + 1);
  if (mminlength > 0) {
    int fparents=0;
    for (int i=0; i < item; i++) {
      if (buf3[i] >= minsupp) {
        fparents+=1;
      }
    }
    if (fparents < mminlength) {
      return;
    }
  }
  final int last=item - 1;
  FPTree proj=new FPTree(item);
  for (FPNode cur=header[item]; cur != null; cur=cur.sibling) {
    int j=buf2.length;
    for (FPNode parent=cur.parent; parent.key >= 0; parent=parent.parent) {
      if (buf3[parent.key] >= minsupp) {
        buf2[--j]=parent.key;
      }
    }
    if (buf2.length - j >= mminlength) {
      proj.insert(proj,buf2,j,buf2.length,cur.count);
    }
  }
  proj.reduceMemory();
  postfix[plen++]=item;
  if (plen >= minlength && plen <= maxlength) {
    col.collect(support,postfix,0,plen);
  }
  for (int j=last; j >= 0; j--) {
    proj.extract(minsupp,minlength,maxlength,j,postfix,plen,buf2,buf3,destruct,col);
  }
  if (destruct) {
    header[item]=null;
  }
}

private void extract ( int minsupp , int minlength , int maxlength , int item , int [ ] postfix , int plen , int [ ] buf2 , int [ ] buf3 , boolean destruct , Collector col ) { if ( header [ item ] == null ) { return ; } if ( header [ item ] . sibling == null ) { if ( header [ item ] . count < minsupp ) { return ; } extractLinear ( header [ item ] . count , minsupp , minlength , maxlength , item , postfix , plen , buf2 , col ) ; if ( destruct ) { Arrays . fill ( header , null ) ; } return ; } int support = 0 ; for ( FPNode cur = header [ item ] ; cur != null ; cur = cur . sibling ) { support += cur . count ; } if ( support < minsupp ) { return ; } Arrays . fill ( buf3 , 0 ) ; for ( FPNode cur = header [ item ] ; cur != null ; cur = cur . sibling ) { for ( FPNode parent = cur . parent ; parent . key >= 0 ; parent = parent . parent ) { buf3 [ parent . key ] += cur . count ; } } final int mminlength = minlength - ( plen + 1 ) ; if ( mminlength > 0 ) { int fparents = 0 ; for ( int i = 0 ; i < item ; i ++ ) { if ( buf3 [ i ] >= minsupp ) { fparents += 1 ; } } if ( fparents < mminlength ) { return ; } } final int last = item - 1 ; FPTree proj = new FPTree ( item ) ; for ( FPNode cur = header [ item ] ; cur != null ; cur = cur . sibling ) { int j = buf2 . length ; for ( FPNode parent = cur . parent ; parent . key >= 0 ; parent = parent . parent ) { if ( buf3 [ parent . key ] >= minsupp ) { buf2 [ -- j ] = parent . key ; } } if ( buf2 . length - j >= mminlength ) { proj . insert ( proj , buf2 , j , buf2 . length , cur . count ) ; } } proj . reduceMemory ( ) ; postfix [ plen ++ ] = item ; if ( plen >= minlength && plen <= maxlength ) { col . collect ( support , postfix , 0 , plen ) ; } for ( int j = last ; j >= 0 ; j -- ) { proj . extract ( minsupp , minlength , maxlength , j , postfix , plen , buf2 , buf3 , destruct , col ) ; } if ( destruct ) { header [ item ] = null ; } }
extract itemsets ending in the given item .
