当前位置: 首页>>代码示例>>C++>>正文


C++ BitString::getLength方法代码示例

本文整理汇总了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;
	}
开发者ID:MarioAriasGa,项目名称:libcds,代码行数:15,代码来源:BitSequenceSDArray.cpp

示例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;
}
开发者ID:migumar2,项目名称:libCSD,代码行数:35,代码来源:testBitSequence.cpp

示例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);
 }
开发者ID:migumar2,项目名称:libCSD,代码行数:26,代码来源:BitSequenceRG.cpp

示例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));
        }
    }
}
开发者ID:rkonow,项目名称:libcds_fast_select,代码行数:46,代码来源:BitSequenceRGK.cpp

示例5: build

BitSequenceRRR::BitSequenceRRR(const BitString & bs, uint sample_rate) {
    build(bs.getData(),bs.getLength(),sample_rate);
}
开发者ID:mpetri,项目名称:libcds,代码行数:3,代码来源:BitSequenceRRR.cpp


注:本文中的BitString::getLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。