fn calc_lms_pos<T: Integer + Unsigned + NumCast + Copy + Debug>(
        &mut self,
        text: &[T],
        pos_types: &PosTypes,
    ) {
        let n = text.len();

        // collect LMS positions
        self.lms_pos.clear();
        let mut i = 0;
        for r in 0..n {
            if pos_types.is_lms_pos(r) {
                self.lms_pos.push(r);
                self.reduced_text_pos[r] = i;
                i += 1;
            }
        }

        // sort LMS substrings by applying step 2 with unsorted LMS positions
        self.calc_pos(text, pos_types);

        let lms_substring_count = self.lms_pos.len();

        if lms_substring_count <= std::u8::MAX as usize {
            self.sort_lms_suffixes::<T, u8>(text, pos_types, lms_substring_count);
        } else if lms_substring_count <= std::u16::MAX as usize {
            self.sort_lms_suffixes::<T, u16>(text, pos_types, lms_substring_count);
        } else if lms_substring_count <= std::u32::MAX as usize {
            self.sort_lms_suffixes::<T, u32>(text, pos_types, lms_substring_count);
        } else {
            self.sort_lms_suffixes::<T, u64>(text, pos_types, lms_substring_count);
        }
    }
/// Step 1 of the SAIS algorithm.
Step 1 of the SAIS algorithm.
Step 1 of the SAIS algorithm .
fn calc_lms_pos<T: Integer + Unsigned + NumCast + Copy + Debug>(
        &mut self,
        text: &[T],
        pos_types: &PosTypes,
    ) {
        let n = text.len();
        // collect LMS positions
        self.lms_pos.clear();
        let mut i = 0;
        for r in 0..n {
            if pos_types.is_lms_pos(r) {
                self.lms_pos.push(r);
                self.reduced_text_pos[r] = i;
                i += 1;
            }
        }
        // sort LMS substrings by applying step 2 with unsorted LMS positions
        self.calc_pos(text, pos_types);
        let lms_substring_count = self.lms_pos.len();
        if lms_substring_count <= std::u8::MAX as usize {
            self.sort_lms_suffixes::<T, u8>(text, pos_types, lms_substring_count);
        } else if lms_substring_count <= std::u16::MAX as usize {
            self.sort_lms_suffixes::<T, u16>(text, pos_types, lms_substring_count);
        } else if lms_substring_count <= std::u32::MAX as usize {
            self.sort_lms_suffixes::<T, u32>(text, pos_types, lms_substring_count);
        } else {
            self.sort_lms_suffixes::<T, u64>(text, pos_types, lms_substring_count);
        }
    }
fn calc_lms_pos < T : Integer + Unsigned + NumCast + Copy + Debug > ( & mut self , text : & [ T ] , pos_types : & PosTypes , ) { let n = text . len ( ) ; // collect LMS positions self . lms_pos . clear ( ) ; let mut i = 0 ; for r in 0 .. n { if pos_types . is_lms_pos ( r ) { self . lms_pos . push ( r ) ; self . reduced_text_pos [ r ] = i ; i += 1 ; } } // sort LMS substrings by applying step 2 with unsorted LMS positions self . calc_pos ( text , pos_types ) ; let lms_substring_count = self . lms_pos . len ( ) ; if lms_substring_count <= std :: u8 :: MAX as usize { self . sort_lms_suffixes :: < T , u8 > ( text , pos_types , lms_substring_count ) ; } else if lms_substring_count <= std :: u16 :: MAX as usize { self . sort_lms_suffixes :: < T , u16 > ( text , pos_types , lms_substring_count ) ; } else if lms_substring_count <= std :: u32 :: MAX as usize { self . sort_lms_suffixes :: < T , u32 > ( text , pos_types , lms_substring_count ) ; } else { self . sort_lms_suffixes :: < T , u64 > ( text , pos_types , lms_substring_count ) ; } }
Step 1 of the SAIS algorithm.
Step 1 of the SAIS algorithm .
&mut self
text
&[T]
pos_types
&PosTypes
&mut self
text
&[T]
pos_types
&PosTypes