예제 #1
0
BitSequenceRG::BitSequenceRG( uint *bitarray, size_t _n, uint _factor) {
    /*cout << "*****" << endl;
    cout << bitarray << endl;
    cout << _n << endl;
    cout << _factor << endl; */
    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);
}
예제 #2
0
	/*
	 * number of bits equal to b before position i EXCLUDED
	 */
	uint64_t rank(uint64_t i, bool b = true){

		return b ? rank1(i) : rank0(i);

	}
예제 #3
0
	/*
	 * position of i-th bit set. 0 =< i < rank(size(),1)
	 */
	uint64_t select1(uint64_t i){

		assert(i<rank1(size()));
		return spsi_.search(i+1);

	}
예제 #4
0
bool static_bitsequence::access(unsigned int i) {
  return (rank1(i)-(i!=0?rank1(i-1):0))>0;
}
예제 #5
0
unsigned int static_bitsequence::rank0(unsigned int i) {
	return i+1-rank1(i);
}
예제 #6
0
size_t BitSequence::selectPrev1(const size_t i) const {
    size_t v = rank1(i);
    if (v < 2) return (size_t) -1;
    return select1(v - 1);
}
예제 #7
0
size_t BitSequence::selectNext1(const size_t i) const {
    return select1((i == 0 ? 0 : rank1(i - 1)) + 1);
}
예제 #8
0
 constexpr unsigned long Waveletmatrix <alphabet_num, length>::access(const position_t index) const
 {
     return rank1(index) - rank1(index - 1);
 }
예제 #9
0
bool BitSequence::access(const size_t i) const {
    return (rank1(i) - (i != 0 ? rank1(i - 1) : 0)) > 0;
}
예제 #10
0
uint64_t BitArray::rank(bit_t bit, uint64_t pos) const
{
  assert(isBuild);
  return bit ? rank1(pos) : (pos - rank1(pos)+1);
}
예제 #11
0
			/**
			 * return number of 0 bits up to (and including) index i
			 * @param i
			 * @return inverse population count
			 **/
			uint64_t rank0(uint64_t const i) const
			{
				return (i+1) - rank1(i);
			}
예제 #12
0
	size_t rank(bool b, size_t pos) const
	{
		if (b) return rank1(pos);
		return rank0(pos);
	}
예제 #13
0
	size_t rank0(size_t pos) const
	{
		return pos - rank1(pos);
	}
예제 #14
0
	/*
	 * total number of bits set
	 */
	uint64_t rank1(){

		return rank1(size());


	}
예제 #15
0
size_t BitSequence::rank0(const size_t i) const {
    return i + 1 - rank1(i);
}
예제 #16
0
size_t BitSequenceRRR::rank0(size_t i) const
{
    if(i+1==0) return 0;
    return 1+i-rank1(i);
}
예제 #17
0
 /**
  * @brief Returns Number of the bits equal to `b` up to position `i`
  *
  * @param[in] i Index of the bit vector
  * @param[in] b Boolean value that indicates bit type.(true = 1, false = 0)
  *
  * @return Number of the bits
  */
 FORCE_INLINE  uint64_t rank(uint64_t i, bool b = true) const {
     return b ? rank1(i) : rank0(i);
 }