docs: protected List<SparseItemset> buildFrequentTwoItemsets(List<OneItemset> oneitems, final Relation<BitVector> relation, final int dim, final int needed, DBIDs ids, ArrayModifiableDBIDs survivors) {
      int f1 = 0;
      long[] mask = BitsUtil.zero(dim);
      for(OneItemset supported : oneitems) {
        BitsUtil.setI(mask, supported.item);
        f1++;
      }
      if(LOG.isStatistics()) {
        LOG.statistics(new LongStatistic(STAT + "2-items.candidates", f1 * (long) (f1 - 1)));
      }
      // We quite aggressively size the map, assuming that almost each combination
      // is present somewhere. If this won't fit into memory, we're likely running
      // OOM somewhere later anyway!
      Long2IntOpenHashMap map = new Long2IntOpenHashMap((f1 * (f1 - 1)) >>> 1);
      final long[] scratch = BitsUtil.zero(dim);
      for(DBIDIter iditer = ids.iter(); iditer.valid(); iditer.advance()) {
        BitsUtil.setI(scratch, mask);
        relation.get(iditer).andOnto(scratch);
        int lives = 0;
        for(int i = BitsUtil.nextSetBit(scratch, 0); i >= 0; i = BitsUtil.nextSetBit(scratch, i + 1)) {
          for(int j = BitsUtil.nextSetBit(scratch, i + 1); j >= 0; j = BitsUtil.nextSetBit(scratch, j + 1)) {
            long key = (((long) i) << 32) | j;
            map.put(key, 1 + map.get(key));
            ++lives;
          }
        }
        if(lives > 2) {
          survivors.add(iditer);
        }
      }
      // Generate candidates of length 2.
      List<SparseItemset> frequent = new ArrayList<>(f1 * (int) FastMath.sqrt(f1));
      for(ObjectIterator<Long2IntMap.Entry> iter = map.long2IntEntrySet().fastIterator(); iter.hasNext();) {
        Long2IntMap.Entry entry = iter.next();
        if(entry.getIntValue() >= needed) {
          int ii = (int) (entry.getLongKey() >>> 32);
          int ij = (int) (entry.getLongKey() & -1L);
          frequent.add(new SparseItemset(new int[] { ii, ij }, entry.getIntValue()));
        }
      }
      // The hashmap may produce them out of order.
      Collections.sort(frequent);
      if(LOG.isStatistics()) {
        LOG.statistics(new LongStatistic(STAT + "2-items.frequent", frequent.size()));
      }
      return frequent;
    }