public override int Rank1(int bit_index)
{
if (bit_index < 0) {
return 0;
}
int container_index = (bit_index) >> 5;
int start_index = (container_index) / this.BlockSize;
int abs_index = start_index / this.SuperBlockSize;
int rel_index = start_index;
int sba_index = abs_index;
start_index *= this.BlockSize;
// the whole thing is to floor in blocksize blocks
int acc_rank = 0;
if (abs_index > 0) {
acc_rank += this.SuperBlocks[abs_index - 1];
abs_index *= this.SuperBlockSize;
}
if (rel_index > abs_index) {
acc_rank += this.Blocks[rel_index - sba_index - 1];
}
var uuu = BitAccess.Rank1(this.BitBlocks, start_index, container_index - start_index, (bit_index & 31));
acc_rank += uuu;
return acc_rank;
}