fn iterate<P>(
    queue: &mut Vec<VBox>,
    comparator: P,
    target: u8,
    histogram: &[i32],
) -> Result<(), Error>
    where P: FnMut(&VBox, &VBox) -> cmp::Ordering + Copy
{
    let mut color = 1;

    for _ in 0..MAX_ITERATIONS {
        if let Some(mut vbox) = queue.last().cloned() {
            if vbox.count == 0 {
                queue.sort_by(comparator);
                continue;
            }
            queue.pop();

            // Do the cut.
            let vboxes = apply_median_cut(histogram, &mut vbox)?;
            queue.push(vboxes.0.clone());
            if let Some(ref vb) = vboxes.1 {
                queue.push(vb.clone());
                color += 1;
            }

            queue.sort_by(comparator);

            if color >= target {
               break;
            }
        }
    }

    Ok(())
}
// Inner function to do the iteration.
Inner function to do the iteration.
Inner function to do the iteration .
fn iterate<P>(
    queue: &mut Vec<VBox>,
    comparator: P,
    target: u8,
    histogram: &[i32],
) -> Result<(), Error>
    where P: FnMut(&VBox, &VBox) -> cmp::Ordering + Copy
{
    let mut color = 1;
    for _ in 0..MAX_ITERATIONS {
        if let Some(mut vbox) = queue.last().cloned() {
            if vbox.count == 0 {
                queue.sort_by(comparator);
                continue;
            }
            queue.pop();
            // Do the cut.
            let vboxes = apply_median_cut(histogram, &mut vbox)?;
            queue.push(vboxes.0.clone());
            if let Some(ref vb) = vboxes.1 {
                queue.push(vb.clone());
                color += 1;
            }
            queue.sort_by(comparator);
            if color >= target {
               break;
            }
        }
    }
    Ok(())
}
fn iterate < P > ( queue : & mut Vec < VBox > , comparator : P , target : u8 , histogram : & [ i32 ] , ) -> Result < ( ) , Error > where P : FnMut ( & VBox , & VBox ) -> cmp :: Ordering + Copy { let mut color = 1 ; for _ in 0 .. MAX_ITERATIONS { if let Some ( mut vbox ) = queue . last ( ) . cloned ( ) { if vbox . count == 0 { queue . sort_by ( comparator ) ; continue ; } queue . pop ( ) ; // Do the cut. let vboxes = apply_median_cut ( histogram , & mut vbox ) ? ; queue . push ( vboxes . 0 . clone ( ) ) ; if let Some ( ref vb ) = vboxes . 1 { queue . push ( vb . clone ( ) ) ; color += 1 ; } queue . sort_by ( comparator ) ; if color >= target { break ; } } } Ok ( ( ) ) }
Inner function to do the iteration.
Inner function to do the iteration .
queue
&mut Vec<VBox>
comparator
P
target
u8
histogram
&[i32]
queue
&mut Vec<VBox>
comparator
P
target
u8
histogram
&[i32]