docs: private int[] buildIndex(final int[] counts, int[] positions, int minsupp) {
      // Count the number of frequent items:
      int numfreq = 0;
      for(int i = 0; i < counts.length; i++) {
        if(counts[i] >= minsupp) {
          ++numfreq;
        }
      }
      // Build the index table
      int[] idx = new int[numfreq];
      for(int i = 0, j = 0; i < counts.length; i++) {
        if(counts[i] >= minsupp) {
          idx[j++] = i;
        }
      }
      IntegerArrayQuickSort.sort(idx, (x, y) -> Integer.compare(counts[y], counts[x]));
      Arrays.fill(positions, -1);
      for(int i = 0; i < idx.length; i++) {
        positions[idx[i]] = i;
      }
      return idx;
    }