fn compute_rating<const COMMON: bool>(mut values: Vec<DiagnosticNumber>, mut pos: isize) -> usize {
    let mut ones = Vec::with_capacity(values.len());
    let mut zeroes = Vec::with_capacity(values.len());
    loop {
        if values.len() == 1 || pos < 0 {
            return values[0] as usize;
        } else {
            ones.clear();
            zeroes.clear();
            for &v in &values {
                if ((v >> pos) & 1) > 0 {
                    ones.push(v);
                } else {
                    zeroes.push(v);
                }
            }
            pos -= 1;
            if COMMON ^ (ones.len() >= zeroes.len()) {
                std::mem::swap(&mut values, &mut zeroes);
            } else {
                std::mem::swap(&mut values, &mut ones);
            }
        }
    }
}
/// Recursively computes an oxygen or carbon dioxyde rating
///
/// Parameters:
/// values: numbers to consider
/// pos: position of the bit to consider. 0=LSB
/// common: consider the most common bit or not
Recursively computes an oxygen or carbon dioxyde rating
Parameters:
values: numbers to consider
pos: position of the bit to consider. 0=LSB
common: consider the most common bit or not
Recursively computes an oxygen or carbon dioxyde rating Parameters : values : numbers to consider pos : position of the bit to consider . 0 = LSB common : consider the most common bit or not
fn compute_rating<const COMMON: bool>(mut values: Vec<DiagnosticNumber>, mut pos: isize) -> usize {
    let mut ones = Vec::with_capacity(values.len());
    let mut zeroes = Vec::with_capacity(values.len());
    loop {
        if values.len() == 1 || pos < 0 {
            return values[0] as usize;
        } else {
            ones.clear();
            zeroes.clear();
            for &v in &values {
                if ((v >> pos) & 1) > 0 {
                    ones.push(v);
                } else {
                    zeroes.push(v);
                }
            }
            pos -= 1;
            if COMMON ^ (ones.len() >= zeroes.len()) {
                std::mem::swap(&mut values, &mut zeroes);
            } else {
                std::mem::swap(&mut values, &mut ones);
            }
        }
    }
}
fn compute_rating < const COMMON : bool > ( mut values : Vec < DiagnosticNumber > , mut pos : isize ) -> usize { let mut ones = Vec :: with_capacity ( values . len ( ) ) ; let mut zeroes = Vec :: with_capacity ( values . len ( ) ) ; loop { if values . len ( ) == 1 || pos < 0 { return values [ 0 ] as usize ; } else { ones . clear ( ) ; zeroes . clear ( ) ; for & v in & values { if ( ( v >> pos ) & 1 ) > 0 { ones . push ( v ) ; } else { zeroes . push ( v ) ; } } pos -= 1 ; if COMMON ^ ( ones . len ( ) >= zeroes . len ( ) ) { std :: mem :: swap ( & mut values , & mut zeroes ) ; } else { std :: mem :: swap ( & mut values , & mut ones ) ; } } } }
Recursively computes an oxygen or carbon dioxyde rating
Parameters:
values: numbers to consider
pos: position of the bit to consider.
Recursively computes an oxygen or carbon dioxyde rating Parameters : values : numbers to consider pos : position of the bit to consider .
values
Vec<DiagnosticNumber>
pos
isize