pub(crate) fn remove_chunks_exceeding_max_count(graph: &mut Graph, query: &Query) {
    let mut counts_from_required_chunks = Breakdown::zero(query.music_types.len());
    for chunk in graph.chunks.values() {
        if chunk.required {
            counts_from_required_chunks += &chunk.music;
        }
    }

    for (music_ty_idx, count_from_required) in counts_from_required_chunks
        .counts
        .iter()
        .copied()
        .enumerate()
    {
        let music_type = &query.music_types[music_ty_idx];
        if let Some(count_limit) = music_type.count_range().max {
            let max_count_left_per_chunk = count_limit.checked_sub(count_from_required).expect(
                "Search can't be completed because the required chunks exceed a maximum music count.",
            );
            // Remove any chunks which exceed the count on their own
            graph
                .chunks
                .retain(|_id, chunk| chunk.music.counts[music_ty_idx] <= max_count_left_per_chunk);
        }
    }
}
/// Remove any chunk which exceeds the max count for any music type.  Usually this max count will be
/// 0 (i.e. any chunks with that music should be removed).
Remove any chunk which exceeds the max count for any music type.  Usually this max count will be
0 .
Remove any chunk which exceeds the max count for any music type . Usually this max count will be 0 .
pub(crate) fn remove_chunks_exceeding_max_count(graph: &mut Graph, query: &Query) {
    let mut counts_from_required_chunks = Breakdown::zero(query.music_types.len());
    for chunk in graph.chunks.values() {
        if chunk.required {
            counts_from_required_chunks += &chunk.music;
        }
    }
    for (music_ty_idx, count_from_required) in counts_from_required_chunks
        .counts
        .iter()
        .copied()
        .enumerate()
    {
        let music_type = &query.music_types[music_ty_idx];
        if let Some(count_limit) = music_type.count_range().max {
            let max_count_left_per_chunk = count_limit.checked_sub(count_from_required).expect(
                "Search can't be completed because the required chunks exceed a maximum music count.",
            );
            // Remove any chunks which exceed the count on their own
            graph
                .chunks
                .retain(|_id, chunk| chunk.music.counts[music_ty_idx] <= max_count_left_per_chunk);
        }
    }
}
pub ( crate ) fn remove_chunks_exceeding_max_count ( graph : & mut Graph , query : & Query ) { let mut counts_from_required_chunks = Breakdown :: zero ( query . music_types . len ( ) ) ; for chunk in graph . chunks . values ( ) { if chunk . required { counts_from_required_chunks += & chunk . music ; } } for ( music_ty_idx , count_from_required ) in counts_from_required_chunks . counts . iter ( ) . copied ( ) . enumerate ( ) { let music_type = & query . music_types [ music_ty_idx ] ; if let Some ( count_limit ) = music_type . count_range ( ) . max { let max_count_left_per_chunk = count_limit . checked_sub ( count_from_required ) . expect ( " " , ) ; // Remove any chunks which exceed the count on their own graph . chunks . retain ( | _id , chunk | chunk . music . counts [ music_ty_idx ] <= max_count_left_per_chunk ) ; } } }
Remove any chunk which exceeds the max count for any music type.
Remove any chunk which exceeds the max count for any music type .
graph
&mut Graph
query
&Query
graph
&mut Graph
query
&Query