protected List<SparseItemset> frequentItemsetsSparse(List<SparseItemset> candidates, Relation<BitVector> relation, int needed, DBIDs ids, ArrayModifiableDBIDs survivors, int length) {
    // Current search interval:
    int begin = 0, end = candidates.size();
    int[] scratchi = new int[length], iters = new int[length];
    SparseItemset scratch = new SparseItemset(scratchi);
    for(DBIDIter iditer = ids.iter(); iditer.valid(); iditer.advance()) {
      BitVector bv = relation.get(iditer);
      if(!initializeSearchItemset(bv, scratchi, iters)) {
        continue;
      }
      int lives = 0;
      while(begin < end) {
        begin = binarySearch(candidates, scratch, begin, end);
        if(begin > 0) {
          candidates.get(begin).increaseSupport();
          ++lives;
        }
        else {
          begin = (-begin) - 1;
        }
        if(begin >= end || !nextSearchItemset(bv, scratchi, iters)) {
          break;
        }
      }
      for(Itemset candidate : candidates) {
        if(candidate.containedIn(bv)) {
          candidate.increaseSupport();
          ++lives;
        }
      }
      if(lives > length) {
        survivors.add(iditer);
      }
    }
    // Retain only those with minimum support:
    List<SparseItemset> frequent = new ArrayList<>(candidates.size());
    for(Iterator<SparseItemset> iter = candidates.iterator(); iter.hasNext();) {
      final SparseItemset candidate = iter.next();
      if(candidate.getSupport() >= needed) {
        frequent.add(candidate);
      }
    }
    return frequent;
  }
protected List < SparseItemset > frequentItemsetsSparse ( List < SparseItemset > candidates , Relation < BitVector > relation , int needed , DBIDs ids , ArrayModifiableDBIDs survivors , int length ) { int begin = 0 , end = candidates . size ( ) ; int [ ] scratchi = new int [ length ] , iters = new int [ length ] ; SparseItemset scratch = new SparseItemset ( scratchi ) ; for ( DBIDIter iditer = ids . iter ( ) ; iditer . valid ( ) ; iditer . advance ( ) ) { BitVector bv = relation . get ( iditer ) ; if ( ! initializeSearchItemset ( bv , scratchi , iters ) ) { continue ; } int lives = 0 ; while ( begin < end ) { begin = binarySearch ( candidates , scratch , begin , end ) ; if ( begin > 0 ) { candidates . get ( begin ) . increaseSupport ( ) ; ++ lives ; } else { begin = ( - begin ) - 1 ; } if ( begin >= end || ! nextSearchItemset ( bv , scratchi , iters ) ) { break ; } } for ( Itemset candidate : candidates ) { if ( candidate . containedIn ( bv ) ) { candidate . increaseSupport ( ) ; ++ lives ; } } if ( lives > length ) { survivors . add ( iditer ) ; } } List < SparseItemset > frequent = new ArrayList < > ( candidates . size ( ) ) ; for ( Iterator < SparseItemset > iter = candidates . iterator ( ) ; iter . hasNext ( ) ; ) { final SparseItemset candidate = iter . next ( ) ; if ( candidate . getSupport ( ) >= needed ) { frequent . add ( candidate ) ; } } return frequent ; }
Returns the frequent BitSets out of the given BitSets with respect to the
given database. Optimized implementation for SparseItemset.

@param candidates the candidates to be evaluated
@param relation the database to evaluate the candidates on
@param needed Minimum support needed
@param ids Objects to process
@param survivors Output: objects that had at least two 1-frequent items.
@param length Itemset length
@return Itemsets with sufficient support