private List<Swatch> generateAverageColors(Collection<Vbox> vboxes) {
   ArrayList<Swatch> colors = new ArrayList<>(vboxes.size());
   for (Vbox vbox : vboxes) {
     Swatch swatch = vbox.getAverageColor();
     if (!shouldIgnoreColor(swatch)) {
       // As we're averaging a color box, we can still get colors which we do not want, so
       // we check again here
       colors.add(swatch);
     }
   }
   return colors;
 }
  /**
   * Iterate through the {@link java.util.Queue}, popping {@link ColorCutQuantizer.Vbox} objects
   * from the queue and splitting them. Once split, the new box and the remaining box are offered
   * back to the queue.
   *
   * @param queue {@link java.util.PriorityQueue} to poll for boxes
   * @param maxSize Maximum amount of boxes to split
   */
  private void splitBoxes(final PriorityQueue<Vbox> queue, final int maxSize) {
    while (queue.size() < maxSize) {
      final Vbox vbox = queue.poll();

      if (vbox != null && vbox.canSplit()) {
        // First split the box, and offer the result
        queue.offer(vbox.splitBox());

        if (LOG_TIMINGS) {
          mTimingLogger.addSplit("Box split");
        }
        // Then offer the box back
        queue.offer(vbox);
      } else {
        if (LOG_TIMINGS) {
          mTimingLogger.addSplit("All boxes split");
        }
        // If we get here then there are no more boxes to split, so return
        return;
      }
    }
  }
 @Override
 public int compare(Vbox lhs, Vbox rhs) {
   return rhs.getVolume() - lhs.getVolume();
 }