/// Compute the number of occurrences of symbol val in the original text up to position p (inclusive).
/// Complexity O(1).
Compute the number of occurrences of symbol val in the original text up to position p (inclusive).
Compute the number of occurrences of symbol val in the original text up to position p ( inclusive ) .
pub fn rank(&self, val: u8, p: u64) -> u64 {
        assert!(
            !self.check_overflow(p),
            "Invalid p (it must be in range 0..wm_size-1"
        );
        let height = self.height as usize;
        let mut spos = 0;
        let mut epos = p + 1;
        for level in 0..height {
            let shift = height - level - 1;
            let bit = ((DNA2INT[val as usize] >> shift) & 1) == 1; // get shifted lsb
            if bit {
                spos = self.prank(level, spos, 1) + self.zeros[level];
                epos = self.prank(level, epos, 1) + self.zeros[level];
            } else {
                spos = self.prank(level, spos, 0);
                epos = self.prank(level, epos, 0);
            }
        }
        epos - spos
    }
pub fn rank ( & self , val : u8 , p : u64 ) -> u64 { assert ! ( self check_overflow ( p ) " " ) ; let height = self . height as usize ; let mut spos = 0 ; let mut epos = p + 1 ; for level in 0 .. height { let shift = height - level - 1 ; let bit = ( ( DNA2INT [ val as usize ] >> shift ) & 1 ) == 1 ; // get shifted lsb if bit { spos = self . prank ( level , spos , 1 ) + self . zeros [ level ] ; epos = self . prank ( level , epos , 1 ) + self . zeros [ level ] ; } else { spos = self . prank ( level , spos , 0 ) ; epos = self . prank ( level , epos , 0 ) ; } } epos - spos }
Compute the number of occurrences of symbol val in the original text up to position p (inclusive).
Compute the number of occurrences of symbol val in the original text up to position p ( inclusive ) .
&self
val
u8
p
u64