12 #if defined(_MSC_VER) && defined(_WIN32)
14 #pragma warning (disable : 4231)
16 #if defined(_WIN32) && (defined(_MSC_VER) || defined(__MINGW32__)) && defined(CXX_USE_DLL) && !defined(DLL_EXPORT)
64 typedef uint32_t word_t;
84 void setBit(
const word_t i,
int val);
85 int getBit(
const word_t i)
const;
86 inline void turnOnRawBit(
const word_t i);
87 void erase(word_t i, word_t j);
89 void set(
int val, word_t n);
94 inline void appendByte(
unsigned char);
95 void appendWord(word_t w);
96 inline void appendFill(
int val, word_t n);
98 int operator==(
const bitvector& rhs)
const;
122 word_t count(
const bitvector& mask)
const;
125 void read(
const char *fn);
126 void write(
const char *fn)
const;
127 void write(
int fdes)
const;
132 word_t compressible()
const;
137 inline word_t size()
const throw();
138 inline
void sloppySize(word_t n) const;
139 inline word_t cnt() const;
140 inline word_t count()
const {
return cnt();}
141 inline word_t sloppyCount()
const;
142 inline word_t numFillWords()
const;
145 return (m_vec.size()*
sizeof(word_t) +
sizeof(
bitvector));
151 return (m_vec.size() + 1 + (active.nbits>0)) *
sizeof(word_t);
155 inline static double randomSize(word_t nb, word_t nc);
156 inline static double markovSize(word_t nb, word_t nc,
double f);
157 static double clusteringFactor(word_t nb, word_t nc, word_t sz);
159 void adjustSize(word_t nv, word_t nt);
160 void reserve(
unsigned nb,
unsigned nc,
double cf=0.0);
164 bool empty()
const {
return all0s() && active.val == 0;}
166 std::ostream& print(std::ostream &)
const;
170 inline iterator end();
171 inline iterator begin();
174 class const_iterator;
175 inline const_iterator end()
const;
176 inline const_iterator begin()
const;
180 inline indexSet firstIndexSet()
const;
186 friend class indexSet;
187 friend class iterator;
188 friend class const_iterator;
191 inline bool all0s()
const;
192 inline bool all1s()
const;
196 static const unsigned MAXBITS;
197 static const unsigned SECONDBIT;
198 static const word_t FILLBIT;
199 static const word_t HEADER0;
200 static const word_t HEADER1;
201 static const word_t ALLONES;
202 static const word_t MAXCNT;
214 active_word() : val(0), nbits(0) {};
215 void reset() {val = 0; nbits = 0;};
216 int is_full()
const {
return (nbits >= MAXBITS);};
219 val <<= 1; nbits ++; val += b;
230 run() : isFill(0), fillBit(0), nWords(0), it(0) {};
232 fillBit = (*it > HEADER1);
234 nWords = (*it & MAXCNT);
245 if (nWords > 1) {--nWords;}
246 else {++ it; nWords = 0;}
250 void operator-=(word_t len) {
252 if (nWords == 0) decode();
254 if (nWords > len) {nWords -= len; len = 0;}
255 else if (nWords == len) {nWords = 0; len = 0; ++ it;}
256 else {len -= nWords; ++ it; nWords = 0;}
258 else {-- len; ++ it; nWords = 0;}
263 friend struct active_word;
266 mutable word_t nbits;
269 array_t<word_t> m_vec;
272 word_t count_c1(
const bitvector& mask)
const;
273 word_t count_c2(
const bitvector& mask)
const;
283 void or_c2(
const bitvector& rhs, bitvector& res)
const;
284 void or_c1(
const bitvector& rhs, bitvector& res)
const;
285 void or_c0(
const bitvector& rhs);
286 void or_d1(
const bitvector& rhs);
287 void or_d2(
const bitvector& rhs, bitvector& res)
const;
288 void and_c2(
const bitvector& rhs, bitvector& res)
const;
289 void and_c1(
const bitvector& rhs, bitvector& res)
const;
290 void and_c0(
const bitvector& rhs);
291 void and_d1(
const bitvector& rhs);
292 void and_d2(
const bitvector& rhs, bitvector& res)
const;
293 void xor_c2(
const bitvector& rhs, bitvector& res)
const;
294 void xor_c1(
const bitvector& rhs, bitvector& res)
const;
295 void xor_c0(
const bitvector& rhs);
296 void xor_d1(
const bitvector& rhs);
297 void xor_d2(
const bitvector& rhs, bitvector& res)
const;
298 void minus_c2(
const bitvector& rhs, bitvector& res)
const;
299 void minus_c1(
const bitvector& rhs, bitvector& res)
const;
300 void minus_c1x(
const bitvector& rhs, bitvector& res)
const;
301 void minus_c0(
const bitvector& rhs);
302 void minus_d1(
const bitvector& rhs);
303 void minus_d2(
const bitvector& rhs, bitvector& res)
const;
304 inline void copy_runs(run& it, word_t& nw);
305 inline void copy_runsn(run& it, word_t& nw);
306 inline void copy_fill(array_t<word_t>::iterator& jt, run& it);
307 inline void copy_runs(array_t<word_t>::iterator& jt, run& it,
309 inline void copy_runsn(array_t<word_t>::iterator& jt, run& it,
311 void decompress(array_t<word_t>& tmp)
const;
312 void copy_comp(array_t<word_t>& tmp)
const;
313 inline void append_active();
314 inline void append_counter(
int val, word_t cnt);
315 inline word_t cnt_ones(word_t)
const;
316 inline word_t cnt_bits(word_t)
const;
317 word_t do_cnt()
const throw ();
323 const_iterator() : compressed(0), ind(0), nbits(0), literalvalue(0),
324 fillbit(0), active(0) {}
326 const_iterator(
const const_iterator& r)
327 : compressed(r.compressed), ind(r.ind), nbits(r.nbits),
328 literalvalue(r.literalvalue), fillbit(r.fillbit), active(r.active),
329 end(r.end), begin(r.begin), it(r.it) {};
330 const_iterator& operator=(
const const_iterator& r) {
331 compressed = r.compressed; ind = r.ind; nbits = r.nbits;
332 literalvalue = r.literalvalue; fillbit = r.fillbit; active = r.active;
333 end = r.end; begin = r.begin; it = r.it;
336 inline bool operator*()
const;
337 inline int operator!=(
const const_iterator& rhs)
const throw ();
338 inline int operator==(
const const_iterator& rhs)
const throw ();
340 inline const_iterator& operator++();
341 inline const_iterator& operator--();
342 const_iterator& operator+=(
int incr);
345 ibis::bitvector::word_t compressed;
346 ibis::bitvector::word_t ind;
347 ibis::bitvector::word_t nbits;
348 ibis::bitvector::word_t literalvalue;
350 const active_word* active;
359 friend const_iterator ibis::bitvector::begin()
const;
360 friend const_iterator ibis::bitvector::end()
const;
373 iterator() : compressed(0), ind(0), nbits(0), literalvalue(0), fillbit(0),
374 bitv(0), active(0), vec(0) {}
376 : compressed(r.compressed), ind(r.ind), nbits(r.nbits),
377 literalvalue(r.literalvalue), fillbit(r.fillbit), bitv(r.bitv),
378 active(r.active), vec(r.vec), it(r.it) {};
380 compressed = r.compressed; ind = r.ind; nbits = r.nbits;
381 literalvalue = r.literalvalue; fillbit = r.fillbit; bitv = r.bitv;
382 active = r.active; vec = r.vec; it = r.it;
return *
this;}
388 inline int operator==(
const iterator& rhs)
const throw ();
396 ibis::bitvector::word_t compressed;
397 ibis::bitvector::word_t ind;
398 ibis::bitvector::word_t nbits;
399 ibis::bitvector::word_t literalvalue;
408 friend iterator ibis::bitvector::begin();
409 friend iterator ibis::bitvector::end();
427 : it(rhs.it), end(rhs.end), active(rhs.active), nind(rhs.nind) {
438 ind[10] = rhs.ind[10];
439 ind[11] = rhs.ind[11];
440 ind[12] = rhs.ind[12];
441 ind[13] = rhs.ind[13];
442 ind[14] = rhs.ind[14];
443 ind[15] = rhs.ind[15];
444 ind[16] = rhs.ind[16];
445 ind[17] = rhs.ind[17];
446 ind[18] = rhs.ind[18];
447 ind[19] = rhs.ind[19];
448 ind[20] = rhs.ind[20];
449 ind[21] = rhs.ind[21];
450 ind[22] = rhs.ind[22];
451 ind[23] = rhs.ind[23];
452 ind[24] = rhs.ind[24];
453 ind[25] = rhs.ind[25];
454 ind[26] = rhs.ind[26];
455 ind[27] = rhs.ind[27];
456 ind[28] = rhs.ind[28];
457 ind[29] = rhs.ind[29];
458 ind[30] = rhs.ind[30];
459 ind[31] = rhs.ind[31];
477 ind[10] = rhs.ind[10];
478 ind[11] = rhs.ind[11];
479 ind[12] = rhs.ind[12];
480 ind[13] = rhs.ind[13];
481 ind[14] = rhs.ind[14];
482 ind[15] = rhs.ind[15];
483 ind[16] = rhs.ind[16];
484 ind[17] = rhs.ind[17];
485 ind[18] = rhs.ind[18];
486 ind[19] = rhs.ind[19];
487 ind[20] = rhs.ind[20];
488 ind[21] = rhs.ind[21];
489 ind[22] = rhs.ind[22];
490 ind[23] = rhs.ind[23];
491 ind[24] = rhs.ind[24];
492 ind[25] = rhs.ind[25];
493 ind[26] = rhs.ind[26];
494 ind[27] = rhs.ind[27];
495 ind[28] = rhs.ind[28];
496 ind[29] = rhs.ind[29];
497 ind[30] = rhs.ind[30];
498 ind[31] = rhs.ind[31];
504 bool isRange()
const {
return (nind>=ibis::bitvector::MAXBITS);}
514 friend indexSet ibis::bitvector::firstIndexSet()
const;
519 const active_word* active;
531 pit(): curr(0xFFFFFFFFU) {}
534 inline ibis::bitvector::word_t
operator*()
const;
536 inline void skip(
unsigned);
540 ibis::bitvector::word_t curr;
551 nbits = n-active.nbits;
552 #if defined(WAH_CHECK_SIZE)
553 word_t nb = do_cnt();
556 LOGGER(ibis::gVerbose >= 0)
557 <<
"bitvector::sloppySize -- adjust the number of bits to "
576 else if (active.nbits == 0 || active.val == 0) {
578 (m_vec.size() == 1 &&
580 (m_vec[0]>=HEADER0 && m_vec[0]<HEADER1))))
596 else if (m_vec.size() == 1) {
597 return (m_vec[0] == 0 || (m_vec[0]>=HEADER0 && m_vec[0]<HEADER1));
607 if (m_vec.size() == 1) {
608 return (m_vec[0] == ALLONES || (m_vec[0] > HEADER1));
616 inline ibis::bitvector::word_t
617 ibis::bitvector::cnt_bits(ibis::bitvector::word_t val)
const {
618 return ((val>ALLONES) ? ((val&MAXCNT)*MAXBITS) : MAXBITS);
622 inline ibis::bitvector::word_t
623 ibis::bitvector::cnt_ones(ibis::bitvector::word_t val)
const {
625 static const word_t table[256] = {
626 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
627 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
628 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
629 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
630 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
631 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
632 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
633 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
634 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
635 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
636 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
637 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
638 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
639 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
640 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
641 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8};
642 return table[val&0xFFU] + table[(val>>8)&0xFFU] +
643 table[(val>>16)&0xFFU] + table[(val>>24)&0xFFU];
648 return ((nbits?nbits:(nbits=do_cnt()))+active.nbits);
653 if (nset==0 && !m_vec.empty())
655 return (nset+cnt_ones(active.val));
662 while (it != m_vec.end()) {
663 cnt += (*it >> ibis::bitvector::MAXBITS);
674 nbits = bv.nbits; nset = bv.nset; active = bv.active;
675 m_vec.deepCopy(bv.m_vec);
681 nbits = bv.nbits; nset = bv.nset; active = bv.active;
682 m_vec.deepCopy(bv.m_vec);
688 tmp = bv.nbits; bv.nbits = nbits; nbits = tmp;
689 tmp = bv.nset; bv.nset = nset; nset = tmp;
690 active_word atmp = bv.active;
691 bv.active = active; active = atmp;
692 m_vec.swap(bv.m_vec);
699 inline void ibis::bitvector::append_active() {
705 m_vec.push_back(active.val);
707 else if (active.val == 0) {
708 if (m_vec.back() == 0) {
709 m_vec.back() = (HEADER0 + 2);
711 else if (m_vec.back() >= HEADER0 && m_vec.back() < HEADER1) {
715 m_vec.push_back(active.val);
718 else if (active.val == ALLONES) {
719 if (m_vec.back() == ALLONES) {
720 m_vec.back() = (HEADER1 | 2);
722 else if (m_vec.back() >= HEADER1) {
726 m_vec.push_back(active.val);
730 m_vec.push_back(active.val);
741 inline void ibis::bitvector::append_counter(
int val, word_t cnt) {
742 word_t head = 2 + val;
743 word_t w = (head << SECONDBIT) + cnt;
744 nbits += cnt*MAXBITS;
748 else if ((m_vec.back()>>SECONDBIT) == head) {
751 else if ((m_vec.back()==ALLONES) && head==3) {
752 m_vec.back() = w + 1;
754 else if ((m_vec.back() == 0) && head==2) {
755 m_vec.back() = w + 1;
765 if (active.is_full())
772 if (active.nbits >= MAXBITS)
775 if (active.nbits+8 < MAXBITS) {
780 else if (active.nbits+8 > MAXBITS) {
781 unsigned na = MAXBITS - active.nbits;
782 unsigned hi = (c >> (8 - na));
786 active.nbits = 8 - na;
787 active.val = ((hi << active.nbits) ^ c);
802 if (active.nbits > 0) {
803 word_t tmp = (MAXBITS - active.nbits);
804 if (tmp > n) tmp = n;
809 active.val |= (1U<<tmp) - 1;
810 if (active.nbits >= MAXBITS)
814 word_t cnt = n / MAXBITS;
816 append_counter(val, cnt);
818 active.val = ALLONES;
829 active.val = val*((1U<<n)-1);
838 inline void ibis::bitvector::copy_runs(run& it, word_t& nw) {
840 if (it.isFill == 0) {
841 active.val = *(it.it);
845 else if (it.nWords > 1) {
846 append_counter(it.fillBit, it.nWords);
849 else if (it.nWords == 1) {
850 active.val = (it.fillBit != 0 ? ALLONES : 0);
857 nbits += MAXBITS * nw;
861 if (nw >= it.nWords) {
862 m_vec.push_back(*(it.it));
871 nbits -= MAXBITS * nw;
876 inline void ibis::bitvector::copy_runsn(run& it, word_t& nw) {
878 if (it.isFill == 0) {
879 active.val = ALLONES ^ *(it.it);
883 else if (it.nWords > 1) {
884 append_counter(!it.fillBit, it.nWords);
887 else if (it.nWords == 1) {
888 active.val = (it.fillBit != 0 ? 0 : ALLONES);
895 nbits += MAXBITS * nw;
899 if (nw >= it.nWords) {
900 m_vec.push_back((it.isFill?FILLBIT:ALLONES) ^ *(it.it));
909 nbits -= MAXBITS * nw;
915 inline void ibis::bitvector::copy_fill
916 (array_t<ibis::bitvector::word_t>::iterator& jt, run& it) {
917 if (it.fillBit == 0) {
918 while (it.nWords > 3) {
926 if (it.nWords == 1) {
929 else if (it.nWords == 2) {
930 *jt = 0; jt[1] = 0; jt += 2;
932 else if (it.nWords == 3) {
933 *jt = 0; jt[1] = 0; jt[2] = 0; jt += 3;
937 while (it.nWords > 3) {
945 if (it.nWords == 1) {
948 else if (it.nWords == 2) {
949 *jt = ALLONES; jt[1] = ALLONES; jt += 2;
951 else if (it.nWords == 3) {
952 *jt = ALLONES; jt[1] = ALLONES; jt[2] = ALLONES; jt += 3;
963 inline void ibis::bitvector::copy_runs
964 (array_t<ibis::bitvector::word_t>::iterator& jt, run& it, word_t& nw) {
965 while (nw >= it.nWords && nw > 0) {
966 if (it.isFill != 0) {
967 const array_t<word_t>::iterator iend = jt + it.nWords;
968 if (it.fillBit == 0) {
1000 inline void ibis::bitvector::copy_runsn
1001 (array_t<ibis::bitvector::word_t>::iterator& jt, run& it, word_t& nw) {
1002 while (nw >= it.nWords) {
1003 if (it.isFill != 0) {
1004 const array_t<word_t>::iterator iend = jt + it.nWords;
1005 if (it.fillBit == 0) {
1020 *jt = *(it.it) ^ ALLONES;
1037 it.it = m_vec.begin();
1040 it.active = &active;
1050 it.literalvalue = 0;
1052 it.it = m_vec.end() + 1;
1055 it.active = &active;
1061 it.it = m_vec.begin();
1062 it.begin = m_vec.begin();
1063 it.end = m_vec.end();
1064 it.active = &active;
1071 #if defined(DEBUG) && DEBUG + 0 > 1
1072 if (vec==0 || it<vec->begin() || it>vec->end())
1073 throw "bitvector::const_iterator not initialized correctly.";
1075 if (compressed != 0)
1076 return (fillbit != 0);
1078 return (1 & (literalvalue >> (bitvector::SECONDBIT - ind)));
1083 inline int ibis::bitvector::iterator::operator!=
1085 return (it != rhs.it);
1088 inline int ibis::bitvector::iterator::operator==
1090 return (it == rhs.it);
1093 inline int ibis::bitvector::iterator::operator!=
1095 return (it != rhs.it);
1098 inline int ibis::bitvector::iterator::operator==
1100 return (it == rhs.it);
1105 #if defined(DEBUG) && DEBUG + 0 > 1
1106 if (vec==0 || it<vec->begin() || it>vec->end())
1107 throw "bitvector::iterator not formed correctly.";
1109 if (ind+1<nbits) {++ind;}
1110 else {++ it; decodeWord();}
1116 #if defined(DEBUG) && DEBUG + 0 > 1
1117 if (vec==0 || it<vec->begin() || it>vec->end()+1)
1118 throw "bitvector::iterator not formed correctly.";
1122 if (it <= vec->end()) -- it;
1123 else if (active->nbits) it = vec->end();
1124 else it = vec->end() - 1;
1126 if (nbits) ind = nbits - 1;
1136 it.literalvalue = 0;
1138 it.it = m_vec.end() + 1;
1139 it.begin = m_vec.begin();
1140 it.end = m_vec.end();
1141 it.active = &active;
1147 #if defined(DEBUG) && DEBUG + 0 > 1
1148 if (it==0 || end==0 || it>end || nbits<=ind)
1149 throw "bitvector::const_iterator not initialized correctly.";
1151 if (compressed != 0)
1152 return (fillbit != 0);
1154 return (1 & (literalvalue >> (bitvector::SECONDBIT - ind)));
1159 inline int ibis::bitvector::const_iterator::operator!=
1161 return (it != rhs.it);
1163 inline int ibis::bitvector::const_iterator::operator==
1165 return (it == rhs.it);
1171 #if defined(DEBUG) && DEBUG + 0 > 1
1172 if (it==0 || end==0 || it>end)
1173 throw "bitvector::const_iterator not formed correctly.";
1175 if (ind+1<nbits) {++ind;}
1176 else {++ it; decodeWord();}
1183 #if defined(DEBUG) && DEBUG + 0 > 1
1184 if (it==0 || end==0 || it>end)
1185 throw "bitvector::const_iterator not formed correctly.";
1189 if (it <= end) -- it;
1190 else if (active->nbits) it = end;
1193 if (nbits) ind = nbits - 1;
1203 if (curr < iset.nIndices()) {
1204 if (iset.isRange()) {
1205 return (*iset.indices())+curr;
1208 return iset.indices()[curr];
1218 iset = bv.firstIndexSet();
1226 if (k+curr < iset.nIndices()) {
1231 else if (iset.nIndices() > 0) {
1233 k = iset.nIndices() - curr;
1247 if (curr >= iset.nIndices()) {
1255 if (m_vec.end() > m_vec.begin()) {
1256 is.it = m_vec.begin() - 1;
1257 is.end = m_vec.end();
1263 is.active = &active;
1264 is.ind[0] =
static_cast<word_t
>(-1);
1275 if (nb > 0 && nb >= nc && nb > MAXBITS) {
1276 const double den =
static_cast<double>(nc) /
1277 static_cast<double>(nb);
1278 const word_t nw = nb / MAXBITS;
1279 sz = 3.0 + nw - nw * (pow(1.0-den, static_cast<int>(2*MAXBITS))
1280 + pow(den, static_cast<int>(2*MAXBITS)));
1282 return sz*
sizeof(word_t);
1291 if (nb > 0 && nb >= nc && nb > MAXBITS) {
1292 const double den =
static_cast<double>(nc) /
1293 static_cast<double>(nb);
1294 const word_t nw = nb / MAXBITS;
1295 if ((den <= 0.5 && f > 1.00001) || (den > 0.5 && (1.0-den)*f > den))
1296 sz = ((1.0-den) * pow(1.0-den/((1.0-den)*f),
1297 static_cast<int>(2*MAXBITS-3)) +
1298 den * pow(1.0-1.0/f, static_cast<int>(2*MAXBITS-3)));
1300 sz = (pow(1.0-den, static_cast<int>(2*MAXBITS)) +
1301 pow(den, static_cast<int>(2*MAXBITS)));
1302 sz = 3.0 + nw * (1.0 - sz);
1304 return sz*
sizeof(word_t);
1313 m_vec[ind / MAXBITS] |= (1 << (SECONDBIT - (ind % MAXBITS)));
1317 active.val |= (1 << (active.nbits - (ind - nbits) - 1));
1319 if (ind >= nbits + active.nbits ||
1320 active.val >= (1U << active.nbits)) {
1321 LOGGER(ibis::gVerbose >= 0)
1322 <<
"bitvector::turnOnRawBit(" << ind
1323 <<
") found a bad active word";
1330 #endif // __BITVECTOR_H
int64_t write(int, const void *, int64_t)
A wrapper over POSIX write function.
Definition: util.cpp:999
word_t nIndices() const
Number of indices.
Definition: bitvector.h:508
static word_t bitsPerLiteral()
Return the number of bits in a literal word.
Definition: bitvector.h:154
const_iterator & operator--()
Decrement the iterator. Move back one bit.
Definition: bitvector.h:1182
indexSet(const indexSet &rhs)
Copy constructor.
Definition: bitvector.h:426
bool operator*() const
Dereference the current bit. No error checking.
Definition: bitvector.h:1070
static double markovSize(word_t nb, word_t nc, double f)
Compute the expected size (number of bytes) of a random sequence generated from a Markov process...
Definition: bitvector.h:1289
The iterator that allows modification of bits.
Definition: bitvector.h:371
The const_iterator class. It iterates on the individual bits.
Definition: bitvector.h:321
indexSet & operator++()
Advance to the next code word that is not zero.
Definition: bitvector.cpp:4524
bool all0s() const
Are all bits in regular words 0? It assumes the regular words have been properly compressed and there...
Definition: bitvector.h:592
void init(const ibis::bitvector &)
Initialize the data structure. The.
Definition: bitvector.h:1217
ibis::bitvector::word_t operator*() const
Operator to retrieve the position of the current bit.
Definition: bitvector.h:1202
The current implementation of FastBit is code named IBIS; most data structures and functions are in t...
Definition: bord.h:16
void appendFill(int val, word_t n)
Append n bits of val.
Definition: bitvector.h:800
const word_t * indices() const
Pointer to the indices.
Definition: bitvector.h:506
bool empty() const
Is the bitvector empty? For efficiency reasons, this funciton only works correctly on a properly comp...
Definition: bitvector.h:164
int operator!=(const const_iterator &rhs) const
Comparing two iterators.
Definition: bitvector.h:1084
bitvector & operator+=(const bitvector &bv)
Append a bitvector.
Definition: bitvector.cpp:334
bitvector & copy(const bitvector &bv)
Make a copy. Performs a deep copy.
Definition: bitvector.h:680
const word_t & currentWord() const
The value of the current compressed word.
Definition: bitvector.h:510
void appendByte(unsigned char)
Append all 8 bits of the incoming bytes as literal bits.
Definition: bitvector.h:771
bool operator*() const
Dereference the current bit value. No error checking.
Definition: bitvector.h:1146
iterator & operator--()
Decrement the interator. Move back by one bit.
Definition: bitvector.h:1115
int copy(const char *to, const char *from)
Copy file named "from" to a file named "to".
Definition: util.cpp:894
word_t size() const
Return the total number of bits in the bit sequence.
Definition: bitvector.h:647
word_t sloppyCount() const
Provide a sloppy count of the number of bits that are 1.
Definition: bitvector.h:572
uint32_t getSerialSize() const
Compute the number of bytes in the serialized version of this bitvector object.
Definition: bitvector.h:150
iterator & operator++()
Increment the interator. Move on to the next bit.
Definition: bitvector.h:1104
void next()
Move on to the next bit that is 1.
Definition: bitvector.h:1245
~bitvector()
!< The basic unit of data storage.
Definition: bitvector.h:67
void sloppySize(word_t n) const
Explicitly set the size of the bitvector.
Definition: bitvector.h:550
void erase(word_t i, word_t j)
Remove the bits in the range of [i, j).
Definition: bitvector.cpp:1012
The indexSet stores positions of bits that are one.
Definition: bitvector.h:421
bool isRange() const
Is the index set a consecutive range?
Definition: bitvector.h:504
int64_t read(int, void *, int64_t)
A wrapper over POSIX read function.
Definition: util.cpp:973
const word_t * const_iterator
!< Iterator type.
Definition: array_t.h:27
void clear(ibis::array_t< ibis::bitvector * > &bv)
Clear an array of bit vectors.
Definition: bitvector.cpp:4662
uint32_t bytes() const
Return the number of bytes used by the bitvector object in memory.
Definition: bitvector.h:144
indexSet & operator=(const indexSet &rhs)
Assignment operator.
Definition: bitvector.h:462
A data structure to represent a sequence of bits.
Definition: bitvector.h:62
indexSet()
Default constructor.
Definition: bitvector.h:424
void adjustSize(word_t nv, word_t nt)
Adjust the size of the bit sequence.
Definition: bitvector.cpp:4086
bool all1s() const
Are all bits in regular words 1? It assumes the regular words are properly compressed and therefore o...
Definition: bitvector.h:606
const_iterator & operator++()
Increment the iterator. Move on to the next bit.
Definition: bitvector.h:1170
word_t cnt() const
Return the number of bits that are one.
Definition: bitvector.h:652
const bitvector & operator=(const bitvector &bv)
The assignment operator.
Definition: bitvector.h:673
void turnOnRawBit(const word_t i)
Turn on a single bit in a uncompressed bitvector.
Definition: bitvector.h:1311
static double randomSize(word_t nb, word_t nc)
Compute the expected number of bytes required to store a random sequence.
Definition: bitvector.h:1273
Iterate over the positive positions one at a time.
Definition: bitvector.h:529
word_t numFillWords() const
Return the number of fill words.
Definition: bitvector.h:659
void skip(unsigned)
Skip over next k positive positions.
Definition: bitvector.h:1224
bool isCompressed() const
Does this bit vector use less space than the maximum? Return true if yes, otherwise false...
Definition: bitvector.h:135