docs: private final static <T> void populateFromItemsSketch(
        final int k, final long n, final long bitPattern, final T[] combinedBuffer,
        final int baseBufferCount, final int numSamples, final T[] itemsArr, final long[] cumWtsArr,
        final Comparator<? super T> comparator) {
      long weight = 1;
      int nxt = 0;
      long bits = bitPattern;
      assert bits == (n / (2L * k)); // internal consistency check
      for (int lvl = 0; bits != 0L; lvl++, bits >>>= 1) {
        weight *= 2;
        if ((bits & 1L) > 0L) {
          final int offset = (2 + lvl) * k;
          for (int i = 0; i < k; i++) {
            itemsArr[nxt] = combinedBuffer[i + offset];
            cumWtsArr[nxt] = weight;
            nxt++;
          }
        }
      }
  
      weight = 1; //NOT a mistake! We just copied the highest level; now we need to copy the base buffer
      final int startOfBaseBufferBlock = nxt;
  
      // Copy BaseBuffer over, along with weight = 1
      for (int i = 0; i < baseBufferCount; i++) {
        itemsArr[nxt] = combinedBuffer[i];
        cumWtsArr[nxt] = weight;
        nxt++;
      }
      assert nxt == numSamples;
  
      // Must sort the items that came from the base buffer.
      // Don't need to sort the corresponding weights because they are all the same.
      Arrays.sort(itemsArr, startOfBaseBufferBlock, numSamples, comparator);
      cumWtsArr[numSamples] = 0;
    }