Skip to content

Commit df173b3

Browse files
committed
Tweaking sizeInBits
1 parent acef47f commit df173b3

File tree

2 files changed

+356
-93
lines changed

2 files changed

+356
-93
lines changed

headers/ewah.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ template <class uword = uint32_t> class EWAHBoolArray {
173173
* answer goes into container
174174
* Running time complexity is proportional to the sum of the compressed
175175
* bitmap sizes.
176+
*
177+
* The sizeInBits() of the result is equal to the maximum that of the current
178+
* bitmap's sizeInBits() and that of a.sizeInBits().
176179
*/
177180
void logicaland(const EWAHBoolArray &a, EWAHBoolArray &container) const;
178181

@@ -181,12 +184,19 @@ template <class uword = uint32_t> class EWAHBoolArray {
181184
* Return the answer
182185
* Running time complexity is proportional to the sum of the compressed
183186
* bitmap sizes.
187+
*
188+
* The sizeInBits() of the result is equal to the maximum that of the current
189+
* bitmap's sizeInBits() and that of a.sizeInBits().
184190
*/
185191
EWAHBoolArray logicaland(const EWAHBoolArray &a) const {
186192
EWAHBoolArray answer;
187193
logicaland(a, answer);
188194
return answer;
189195
}
196+
197+
/**
198+
* calls logicaland
199+
*/
190200
EWAHBoolArray operator&(const EWAHBoolArray &a) const {
191201
return logicaland(a);
192202
}
@@ -197,9 +207,15 @@ template <class uword = uint32_t> class EWAHBoolArray {
197207
* Running time complexity is proportional to the sum of the compressed
198208
* bitmap sizes.
199209
*
210+
* The sizeInBits() of the result should be equal to that of the current
211+
* bitmap irrespective of a.sizeInBits().
212+
*
200213
*/
201214
void logicalandnot(const EWAHBoolArray &a, EWAHBoolArray &container) const;
202215

216+
/**
217+
* calls logicalandnot
218+
*/
203219
EWAHBoolArray operator-(const EWAHBoolArray &a) const {
204220
return logicalandnot(a);
205221
}
@@ -209,6 +225,10 @@ template <class uword = uint32_t> class EWAHBoolArray {
209225
* Return the answer
210226
* Running time complexity is proportional to the sum of the compressed
211227
* bitmap sizes.
228+
*
229+
* The sizeInBits() of the result should be equal to that of the current
230+
* bitmap irrespective of a.sizeInBits().
231+
*
212232
*/
213233
EWAHBoolArray logicalandnot(const EWAHBoolArray &a) const {
214234
EWAHBoolArray answer;
@@ -230,6 +250,9 @@ template <class uword = uint32_t> class EWAHBoolArray {
230250
* bitmap sizes.
231251
*
232252
* If you have many bitmaps, see fast_logicalor_tocontainer.
253+
*
254+
* The sizeInBits() of the result is equal to the maximum that of the current
255+
* bitmap's sizeInBits() and that of a.sizeInBits().
233256
*/
234257
void logicalor(const EWAHBoolArray &a, EWAHBoolArray &container) const;
235258

@@ -273,20 +296,28 @@ template <class uword = uint32_t> class EWAHBoolArray {
273296
*
274297
* If you have many bitmaps, see fast_logicalor.
275298
*
299+
* The sizeInBits() of the result is equal to the maximum that of the current
300+
* bitmap's sizeInBits() and that of a.sizeInBits().
276301
*/
277302
EWAHBoolArray logicalor(const EWAHBoolArray &a) const {
278303
EWAHBoolArray answer;
279304
logicalor(a, answer);
280305
return answer;
281306
}
282307

308+
/**
309+
* calls logicalor
310+
*/
283311
EWAHBoolArray operator|(const EWAHBoolArray &a) const { return logicalor(a); }
284312

285313
/**
286314
* computes the logical xor with another compressed bitmap
287315
* answer goes into container
288316
* Running time complexity is proportional to the sum of the compressed
289317
* bitmap sizes.
318+
*
319+
* The sizeInBits() of the result is equal to the maximum that of the current
320+
* bitmap's sizeInBits() and that of a.sizeInBits().
290321
*/
291322
void logicalxor(const EWAHBoolArray &a, EWAHBoolArray &container) const;
292323

@@ -295,13 +326,19 @@ template <class uword = uint32_t> class EWAHBoolArray {
295326
* Return the answer
296327
* Running time complexity is proportional to the sum of the compressed
297328
* bitmap sizes.
329+
*
330+
* The sizeInBits() of the result is equal to the maximum that of the current
331+
* bitmap's sizeInBits() and that of a.sizeInBits().
298332
*/
299333
EWAHBoolArray logicalxor(const EWAHBoolArray &a) const {
300334
EWAHBoolArray answer;
301335
logicalxor(a, answer);
302336
return answer;
303337
}
304338

339+
/**
340+
* calls logicalxor
341+
*/
305342
EWAHBoolArray operator^(const EWAHBoolArray &a) const {
306343
return logicalxor(a);
307344
}
@@ -1717,6 +1754,7 @@ void EWAHBoolArray<uword>::logicalor(const EWAHBoolArray &a,
17171754
const bool i_remains = rlwi.size() > 0;
17181755
BufferedRunningLengthWord<uword> &remaining = i_remains ? rlwi : rlwj;
17191756
remaining.discharge(container);
1757+
container.setSizeInBits(sizeInBits() > a.sizeInBits() ? sizeInBits() : a.sizeInBits());
17201758
}
17211759

17221760
template <class uword>
@@ -1804,6 +1842,7 @@ void EWAHBoolArray<uword>::logicalxor(const EWAHBoolArray &a,
18041842
const bool i_remains = rlwi.size() > 0;
18051843
BufferedRunningLengthWord<uword> &remaining = i_remains ? rlwi : rlwj;
18061844
remaining.discharge(container);
1845+
container.setSizeInBits(sizeInBits() > a.sizeInBits() ? sizeInBits() : a.sizeInBits());
18071846
}
18081847

18091848
template <class uword>
@@ -1899,6 +1938,7 @@ void EWAHBoolArray<uword>::logicaland(const EWAHBoolArray &a,
18991938
}
19001939
}
19011940
container.setSizeInBits(sizeInBits());
1941+
container.setSizeInBits(sizeInBits() > a.sizeInBits() ? sizeInBits() : a.sizeInBits());
19021942
}
19031943

19041944
template <class uword>

0 commit comments

Comments
 (0)