pub fn new(mut input_intervals: Vec<Interval<T>>, min_cov_len: Option<usize>) -> Self {
        let max_comps = (input_intervals.len() as f64).log2().floor() as usize + 1;
        let min_cov_len = min_cov_len.unwrap_or(20); // number of elements ahead to check for cov
        let min_cov = min_cov_len / 2; // the number of elemnts covered to trigger an extraction

        let num_comps; // number of components
        let mut comp_lens = vec![]; // lengths of each component
        let mut comp_idxs = vec![]; // start positions of each component
        let mut max_ends = vec![]; // list of the max end positions

        let min_comp_len = std::cmp::max(64, min_cov_len); // min length of a component

        let input_len = input_intervals.len();
        input_intervals.sort();

        let mut decomposed = vec![];
        if input_len <= min_comp_len {
            num_comps = 1;
            comp_lens.push(input_len);
            comp_idxs.push(0);
            decomposed.append(&mut input_intervals);
        } else {
            let mut curr_comp = 0;
            while curr_comp < max_comps && input_len - decomposed.len() > min_comp_len {
                let mut list1 = vec![];
                let mut list2 = vec![];
                for i in 0..input_intervals.len() {
                    let interval = &input_intervals[i];
                    let mut j = 1;
                    let mut cov = 1;
                    while j < min_comp_len && cov < min_cov && j + i < input_intervals.len() {
                        if input_intervals[j + i].end >= interval.end {
                            cov += 1;
                        }
                        j += 1;
                    }
                    if cov < min_cov {
                        list1.push(input_intervals[i].clone());
                    } else {
                        list2.push(input_intervals[i].clone())
                    }
                }
                // Add the component info to ScAIList
                comp_idxs.push(decomposed.len());
                comp_lens.push(list1.len());
                curr_comp += 1;

                if list2.len() <= min_comp_len || curr_comp == max_comps - 2 {
                    // exit: add L2 to the end
                    if !list2.is_empty() {
                        decomposed.append(&mut list1);
                        comp_idxs.push(decomposed.len());
                        comp_lens.push(list2.len());
                        decomposed.append(&mut list2);
                        curr_comp += 1;
                    }
                } else {
                    decomposed.append(&mut list1);
                    input_intervals = list2;
                }
            }
            num_comps = curr_comp;
        }

        // Augment with maxend
        for j in 0..num_comps {
            let comp_start = comp_idxs[j];
            let comp_end = comp_start + comp_lens[j];
            let mut max_end = decomposed[comp_start].end;
            max_ends.push(max_end);
            for iv in decomposed[comp_start + 1..comp_end].iter() {
                if iv.end > max_end {
                    max_end = iv.end;
                }
                max_ends.push(max_end);
            }
        }

        ScAIList {
            num_comps,
            comp_idxs,
            comp_lens,
            max_ends,
            intervals: decomposed,
        }
    }
/// Create a new ScAIList out of the passed in intervals. The min_cov_len should probably be
/// left as default, which is 20. It dictates how far ahead to look from a given point to
/// determine if that interval covers enough other intervals to be moved to a sublist. The
/// number of intervals it has to cover is equal to min_cov_len / 2. The number of sublists
/// that might be fored is capped at intervals.len().log2(), but if there aren't many overlaps,
/// fewer will be created.
Create a new ScAIList out of the passed in intervals. The min_cov_len should probably be
left as default, which is 20. It dictates how far ahead to look from a given point to
determine if that interval covers enough other intervals to be moved to a sublist. The
number of intervals it has to cover is equal to min_cov_len / 2. The number of sublists
that might be fored is capped at intervals.len().log2(), but if there aren't many overlaps,
fewer will be created.
Create a new ScAIList out of the passed in intervals . The min_cov_len should probably be left as default which is 20 . It dictates how far ahead to look from a given point to determine if that interval covers enough other intervals to be moved to a sublist . The number of intervals it has to cover is equal to min_cov_len / 2 . The number of sublists that might be fored is capped at intervals . len () . log2 () but if there aren ' t many overlaps fewer will be created .
pub fn new(mut input_intervals: Vec<Interval<T>>, min_cov_len: Option<usize>) -> Self {
        let max_comps = (input_intervals.len() as f64).log2().floor() as usize + 1;
        let min_cov_len = min_cov_len.unwrap_or(20); // number of elements ahead to check for cov
        let min_cov = min_cov_len / 2; // the number of elemnts covered to trigger an extraction
        let num_comps; // number of components
        let mut comp_lens = vec![]; // lengths of each component
        let mut comp_idxs = vec![]; // start positions of each component
        let mut max_ends = vec![]; // list of the max end positions
        let min_comp_len = std::cmp::max(64, min_cov_len); // min length of a component
        let input_len = input_intervals.len();
        input_intervals.sort();
        let mut decomposed = vec![];
        if input_len <= min_comp_len {
            num_comps = 1;
            comp_lens.push(input_len);
            comp_idxs.push(0);
            decomposed.append(&mut input_intervals);
        } else {
            let mut curr_comp = 0;
            while curr_comp < max_comps && input_len - decomposed.len() > min_comp_len {
                let mut list1 = vec![];
                let mut list2 = vec![];
                for i in 0..input_intervals.len() {
                    let interval = &input_intervals[i];
                    let mut j = 1;
                    let mut cov = 1;
                    while j < min_comp_len && cov < min_cov && j + i < input_intervals.len() {
                        if input_intervals[j + i].end >= interval.end {
                            cov += 1;
                        }
                        j += 1;
                    }
                    if cov < min_cov {
                        list1.push(input_intervals[i].clone());
                    } else {
                        list2.push(input_intervals[i].clone())
                    }
                }
                // Add the component info to ScAIList
                comp_idxs.push(decomposed.len());
                comp_lens.push(list1.len());
                curr_comp += 1;
                if list2.len() <= min_comp_len || curr_comp == max_comps - 2 {
                    // exit: add L2 to the end
                    if !list2.is_empty() {
                        decomposed.append(&mut list1);
                        comp_idxs.push(decomposed.len());
                        comp_lens.push(list2.len());
                        decomposed.append(&mut list2);
                        curr_comp += 1;
                    }
                } else {
                    decomposed.append(&mut list1);
                    input_intervals = list2;
                }
            }
            num_comps = curr_comp;
        }
        // Augment with maxend
        for j in 0..num_comps {
            let comp_start = comp_idxs[j];
            let comp_end = comp_start + comp_lens[j];
            let mut max_end = decomposed[comp_start].end;
            max_ends.push(max_end);
            for iv in decomposed[comp_start + 1..comp_end].iter() {
                if iv.end > max_end {
                    max_end = iv.end;
                }
                max_ends.push(max_end);
            }
        }
        ScAIList {
            num_comps,
            comp_idxs,
            comp_lens,
            max_ends,
            intervals: decomposed,
        }
    }
pub fn new ( mut input_intervals : Vec < Interval < T > > , min_cov_len : Option < usize > ) -> Self { let max_comps = ( input_intervals . len ( ) as f64 ) . log2 ( ) . floor ( ) as usize + 1 ; let min_cov_len = min_cov_len . unwrap_or ( 20 ) ; // number of elements ahead to check for cov let min_cov = min_cov_len / 2 ; // the number of elemnts covered to trigger an extraction let num_comps ; // number of components let mut comp_lens = vec ! [ ] ; // lengths of each component let mut comp_idxs = vec ! [ ] ; // start positions of each component let mut max_ends = vec ! [ ] ; // list of the max end positions let min_comp_len = std :: cmp :: max ( 64 , min_cov_len ) ; // min length of a component let input_len = input_intervals . len ( ) ; input_intervals . sort ( ) ; let mut decomposed = vec ! [ ] ; if input_len <= min_comp_len { num_comps = 1 ; comp_lens . push ( input_len ) ; comp_idxs . push ( 0 ) ; decomposed . append ( & mut input_intervals ) ; } else { let mut curr_comp = 0 ; while curr_comp < max_comps && input_len - decomposed . len ( ) > min_comp_len { let mut list1 = vec ! [ ] ; let mut list2 = vec ! [ ] ; for i in 0 .. input_intervals . len ( ) { let interval = & input_intervals [ i ] ; let mut j = 1 ; let mut cov = 1 ; while j < min_comp_len && cov < min_cov && j + i < input_intervals . len ( ) { if input_intervals [ j + i ] . end >= interval . end { cov += 1 ; } j += 1 ; } if cov < min_cov { list1 . push ( input_intervals [ i ] . clone ( ) ) ; } else { list2 . push ( input_intervals [ i ] . clone ( ) ) } } // Add the component info to ScAIList comp_idxs . push ( decomposed . len ( ) ) ; comp_lens . push ( list1 . len ( ) ) ; curr_comp += 1 ; if list2 . len ( ) <= min_comp_len || curr_comp == max_comps - 2 { // exit: add L2 to the end if ! list2 . is_empty ( ) { decomposed . append ( & mut list1 ) ; comp_idxs . push ( decomposed . len ( ) ) ; comp_lens . push ( list2 . len ( ) ) ; decomposed . append ( & mut list2 ) ; curr_comp += 1 ; } } else { decomposed . append ( & mut list1 ) ; input_intervals = list2 ; } } num_comps = curr_comp ; } // Augment with maxend for j in 0 .. num_comps { let comp_start = comp_idxs [ j ] ; let comp_end = comp_start + comp_lens [ j ] ; let mut max_end = decomposed [ comp_start ] . end ; max_ends . push ( max_end ) ; for iv in decomposed [ comp_start + 1 .. comp_end ] . iter ( ) { if iv . end > max_end { max_end = iv . end ; } max_ends . push ( max_end ) ; } } ScAIList { num_comps , comp_idxs , comp_lens , max_ends , intervals : decomposed , } }
Create a new ScAIList out of the passed in intervals.
Create a new ScAIList out of the passed in intervals .
input_intervals
Vec<Interval<T>>
min_cov_len
Option<usize>