本文整理汇总了C++中BitString::getLength方法的典型用法代码示例。如果您正苦于以下问题:C++ BitString::getLength方法的具体用法?C++ BitString::getLength怎么用?C++ BitString::getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitString
的用法示例。
在下文中一共展示了BitString::getLength方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
BitSequenceSDArray::BitSequenceSDArray(const BitString & bs) {
uint * tmp_seq = new uint[uint_len(bs.getLength(),1)+1];
ones = 0;
for(uint i=0;i<uint_len(bs.getLength(),1)+1;i++)
tmp_seq[i] = 0;
for(uint i=0;i<bs.getLength();i++)
if(bs[i]) {
__setbit(tmp_seq,i,1);
ones++;
}
if(ones)
selects3_construct(&sd,bs.getLength(),tmp_seq);
this->length = bs.getLength();
delete [] tmp_seq;
}
示例2: testBitSequence
bool testBitSequence(BitString & a, BitSequence * bs) {
size_t rank0SoFar = 0;
size_t rank1SoFar = 0;
for(size_t i=0; i<a.getLength(); i++) {
if(a[i]) {
rank1SoFar++;
if(bs->select1(rank1SoFar)!=i) {
cerr << "SELECT1 ERROR " << i << endl;
return false;
}
if(i>0 && bs->selectNext1(i)!=i) {
cout << "i=" << i << "sn=" << bs->selectNext1(i) << endl;
cerr << "SELECTNEXT1 ERROR" << endl;
return false;
}
} else {
rank0SoFar++;
if(bs->select0(rank0SoFar)!=i) {
cerr << "SELECT0 ERROR" << endl;
return false;
}
if(i>0 && bs->selectNext0(i)!=i) {
cerr << "SELECTNEXT0 ERROR" << endl;
return false;
}
}
if(bs->rank1(i)!=rank1SoFar)
return false;
if(bs->rank0(i)!=rank0SoFar)
return false;
if(bs->access(i)!=a[i])
return false;
}
return true;
}
示例3: BuildRank
BitSequenceRG::BitSequenceRG(const BitString & bs, uint _factor) {
/*cout << "*****" << endl;
cout << bitarray << endl;
cout << _n << endl;
cout << _factor << endl; */
const uint * bitarray = bs.getData();
size_t _n = bs.getLength();
if(_factor==0) exit(-1);
data=new uint[_n/W+1];
for(size_t i=0;i<uint_len(_n,1);i++)
data[i] = bitarray[i];
for(size_t i=uint_len(_n,1);i<_n/W+1;i++)
data[i] = 0;
//this->owner = true;
this->n=_n;
uint lgn=bits(n-1);
this->factor=_factor;
if (_factor==0) this->factor=lgn;
else this->factor=_factor;
b=32;
s=b*this->factor;
integers = n/W+1;
BuildRank();
this->length = n;
this->ones = rank1(n-1);
}
示例4: bits
BitSequenceRGK::BitSequenceRGK(const BitString &bs, uint _factor, uint selectsampling) {
const uint *bitarray = bs.getData();
size_t _n = bs.getLength();
// cout << _factor << endl;
if (_factor == 0) exit(-1);
// cout << "_n/W+1=" << _n/W+1 << endl;
data = new uint[_n / W + 1];
// cout << "_n/W+1=" << _n/W+1 << endl;
for (size_t i = 0; i < uint_len(_n, 1); i++)
data[i] = bitarray[i];
for (size_t i = uint_len(_n, 1); i < _n / W + 1; i++)
data[i] = 0;
//this->owner = true;
this->n = _n;
uint lgn = bits(n - 1);
this->factor = _factor;
if (_factor == 0) this->factor = lgn;
else this->factor = _factor;
b = 32;
s = b * this->factor;
integers = n / W + 1;
BuildRank();
this->length = n;
this->ones = rank1(n - 1);
fastselect0 = true;
fastselect1 = true;
select1sampling = selectsampling;
select0sampling = selectsampling;
if (fastselect1) {
// cout << "entered here" << endl;
this->Stones = new uint[ones / select1sampling + 1];
Stones[0] = 0;
for (size_t i = 0; i <= ones; i += select1sampling) {
if (i == 0) continue;
Stones[i / select1sampling] = this->select1_s(i);
}
}
if (fastselect0) {
this->Stzero = new uint[(n - ones) / select0sampling + 1];
Stzero[0] = 0;
for (size_t i = 0; i <= (n - ones); i += select0sampling) {
if (i == 0) continue;
Stzero[i / select0sampling] = this->select0_s((i));
}
}
}
示例5: build
BitSequenceRRR::BitSequenceRRR(const BitString & bs, uint sample_rate) {
build(bs.getData(),bs.getLength(),sample_rate);
}