/**
  * 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(PriorityQueue <Vbox> queue, int maxSize)
 {
     while (queue.Count < maxSize)
     {
         Vbox vbox = queue.Poll();
         if (vbox != null && vbox.CanSplit())
         {
             // First split the box, and offer the result
             queue.Offer(vbox.SplitBox());
             // Then offer the box back
             queue.Offer(vbox);
         }
         else
         {
             // If we get here then there are no more boxes to split, so return
             return;
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// Iterate through the Queue, popping ColorCutQuantizer.Vbox objects from the queue and splitting them.
        /// Once split, the new box and the remaining box are offered back to the queue.
        /// </summary>
        /// <param name="queue">PriorityQueue to poll for boxes</param>
        /// <param name="maxSize">Maximum amount of boxes to split</param>
        private void SplitBoxes(MaxHeap <Vbox> queue, int maxSize)
        {
            while (queue.Count < maxSize)
            {
                Vbox vbox = queue.ExtractDominating();

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

                    // Then offer the box back
                    queue.Add(vbox);
                }
                else
                {
                    // If we get here then there are no more boxes to split, so return
                    return;
                }
            }
        }