pub fn select(&self, rank: position_t) -> position_t {
        let lut_idx = rank / self.sample_interval;
        let mut rank_left = rank % self.sample_interval;
        // The first slot in select_lut_ stores the position of the first 1 bit.
        // Slot i > 0 stores the position of (i * sample_interval_)-th 1 bit
        if lut_idx == 0 { rank_left -= 1; }

        let pos = self.select_lut[lut_idx];

        if rank_left == 0 { return pos; }

        let mut word_id = pos / K_WORD_SIZE;
        let mut offset = pos % K_WORD_SIZE;
        if offset == K_WORD_SIZE - 1 {
            word_id += 1;
            offset = 0;
        } else {
            offset += 1;
        }
        let mut word: word_t = self.bitvec.get_bits()[word_id] << offset >> offset;  // zero-out most significant bits
        unsafe {
            let mut ones_count_in_word: position_t = core::arch::x86_64::_popcnt64(word as i64) as position_t;
            while ones_count_in_word < rank_left {
                word_id += 1;
                word = self.bitvec.get_bits()[word_id];
                rank_left -= ones_count_in_word;
                ones_count_in_word = core::arch::x86_64::_popcnt64(word as i64) as position_t;
            }
        }
        return word_id * K_WORD_SIZE + select64_popcount_search(word, rank_left as i32) as usize;
    }
// Returns the postion of the rank-th 1 bit.
// posistion is zero-based; rank is one-based.
// E.g., for bitvector: 100101000, select(3) = 5
Returns the postion of the rank-th 1 bit.
posistion is zero-based; rank is one-based.
Returns the postion of the rank - th 1 bit . posistion is zero - based ; rank is one - based .
pub fn select(&self, rank: position_t) -> position_t {
        let lut_idx = rank / self.sample_interval;
        let mut rank_left = rank % self.sample_interval;
        // The first slot in select_lut_ stores the position of the first 1 bit.
        // Slot i > 0 stores the position of (i * sample_interval_)-th 1 bit
        if lut_idx == 0 { rank_left -= 1; }
        let pos = self.select_lut[lut_idx];
        if rank_left == 0 { return pos; }
        let mut word_id = pos / K_WORD_SIZE;
        let mut offset = pos % K_WORD_SIZE;
        if offset == K_WORD_SIZE - 1 {
            word_id += 1;
            offset = 0;
        } else {
            offset += 1;
        }
        let mut word: word_t = self.bitvec.get_bits()[word_id] << offset >> offset;  // zero-out most significant bits
        unsafe {
            let mut ones_count_in_word: position_t = core::arch::x86_64::_popcnt64(word as i64) as position_t;
            while ones_count_in_word < rank_left {
                word_id += 1;
                word = self.bitvec.get_bits()[word_id];
                rank_left -= ones_count_in_word;
                ones_count_in_word = core::arch::x86_64::_popcnt64(word as i64) as position_t;
            }
        }
        return word_id * K_WORD_SIZE + select64_popcount_search(word, rank_left as i32) as usize;
    }
pub fn select ( & self , rank : position_t ) -> position_t { let lut_idx = rank / self . sample_interval ; let mut rank_left = rank % self . sample_interval ; // The first slot in select_lut_ stores the position of the first 1 bit. // Slot i > 0 stores the position of (i * sample_interval_)-th 1 bit if lut_idx == 0 { rank_left -= 1 ; } let pos = self . select_lut [ lut_idx ] ; if rank_left == 0 { return pos ; } let mut word_id = pos / K_WORD_SIZE ; let mut offset = pos % K_WORD_SIZE ; if offset == K_WORD_SIZE - 1 { word_id += 1 ; offset = 0 ; } else { offset += 1 ; } let mut word : word_t = self . bitvec . get_bits ( ) [ word_id ] << offset >> offset ; // zero-out most significant bits unsafe { let mut ones_count_in_word : position_t = core :: arch :: x86_64 :: _popcnt64 ( word as i64 ) as position_t ; while ones_count_in_word < rank_left { word_id += 1 ; word = self . bitvec . get_bits ( ) [ word_id ] ; rank_left -= ones_count_in_word ; ones_count_in_word = core :: arch :: x86_64 :: _popcnt64 ( word as i64 ) as position_t ; } } return word_id * K_WORD_SIZE + select64_popcount_search ( word , rank_left as i32 ) as usize ; }
Returns the postion of the rank-th 1 bit.
Returns the postion of the rank - th 1 bit .
&self
rank
position_t
&self
rank
position_t