code: @SuppressWarnings("unchecked")
    Result getSamplesAsArrays(final Class<?> clazz) {
      if ((r_ + h_) == 0) {
        return null;
      }
  
      // are Array.asList(data_.subList()) copies better?
      final int numSamples = getNumSamples();
      final T[] prunedItems = (T[]) Array.newInstance(clazz, numSamples);
      final double[] prunedWeights = new double[numSamples];
      int j = 0;
      final double rWeight = totalWtR_ / r_;
      for (int i = 0; j < numSamples; ++i) {
        final T item = data_.get(i);
        if (item != null) {
          prunedItems[j] = item;
          prunedWeights[j] = (weights_.get(i) > 0 ? weights_.get(i) : rWeight);
          ++j;
        }
      }
  
      final Result output = new Result();
      output.items = prunedItems;
      output.weights = prunedWeights;
  
      return output;
    }
docs: Returns a VarOptItemsSketch.Result structure containing the items and weights in separate
  lists. The returned list lengths may be smaller than the total capacity.
  
  <p>This method allocates an array of class <em>clazz</em>, which must either match or
  be parent of T. This method should be used when objects in the array are all instances of T
  but are not necessarily instances of the base class.</p>
  
  @param clazz A class to which the items are cast before returning
  @return A Result object containing items and weights.