Skip to content

Commit

Permalink
Merge pull request #3 from themousepotato/update_bundled_ewah
Browse files Browse the repository at this point in the history
Update EWAH from upstream lemire/EWAHBoolArray
  • Loading branch information
matthewturk authored Jul 17, 2021
2 parents eb1bc18 + 414c1b7 commit 49c7bea
Show file tree
Hide file tree
Showing 8 changed files with 1,786 additions and 1,723 deletions.
1 change: 0 additions & 1 deletion ewah_bool_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Top-level package for EWAH Bool Utils."""

__version__ = '0.1.0'

from .ewah_bool_wrap import *
54 changes: 27 additions & 27 deletions ewah_bool_utils/cpp/boolarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@

#ifndef BOOLARRAY_H
#define BOOLARRAY_H
#include <iso646.h> // mostly for Microsoft compilers
#include <stdarg.h>
#include <cassert>
#include <iostream>
#include <vector>
#include <stdexcept>
#include <iso646.h> // mostly for Microsoft compilers
#include <sstream>
#include <stdarg.h>
#include <stdexcept>
#include <vector>

// uncomment this for debugging
//#define EWAHASSERT
#include "ewahutil.h"

namespace ewah {
/**
* A dynamic bitset implementation. (without compression).
*/
Expand Down Expand Up @@ -139,7 +139,7 @@ template <class uword = uint32_t> class BoolArray {
void set(const size_t pos) {
if (pos >= sizeinbits)
padWithZeroes(pos + 1);
buffer[pos / wordinbits] |= (static_cast<uword>(1) << (pos % wordinbits));
buffer[pos / wordinbits] |= static_cast<uword>((static_cast<uword>(1) << (pos % wordinbits)));
}

/**
Expand Down Expand Up @@ -190,9 +190,9 @@ template <class uword = uint32_t> class BoolArray {
}

/**
* Computes the logical and and return the result.
* The current bitmaps is unchanged.
*/
* Computes the logical and and return the result.
* The current bitmaps is unchanged.
*/
BoolArray logicaland(const BoolArray &a) const {
BoolArray answer;
logicaland(a, answer);
Expand All @@ -215,16 +215,16 @@ template <class uword = uint32_t> class BoolArray {
size_t upto = out.buffer.size() < ba.buffer.size() ? out.buffer.size()
: ba.buffer.size();
for (size_t i = 0; i < upto; ++i)
out.buffer[i] = buffer[i] & (~ba.buffer[i]);
out.buffer[i] = static_cast<uword>(buffer[i] & (~ba.buffer[i]));
for (size_t i = upto; i < out.buffer.size(); ++i)
out.buffer[i] = buffer[i];
out.clearBogusBits();
}

/**
* Computes the logical andnot and return the result.
* The current bitmaps is unchanged.
*/
* Computes the logical andnot and return the result.
* The current bitmaps is unchanged.
*/
BoolArray logicalandnot(const BoolArray &a) const {
BoolArray answer;
logicalandnot(a, answer);
Expand Down Expand Up @@ -262,9 +262,9 @@ template <class uword = uint32_t> class BoolArray {
}

/**
* Computes the logical or and return the result.
* The current bitmaps is unchanged.
*/
* Computes the logical or and return the result.
* The current bitmaps is unchanged.
*/
BoolArray logicalor(const BoolArray &a) const {
BoolArray answer;
logicalor(a, answer);
Expand Down Expand Up @@ -296,9 +296,9 @@ template <class uword = uint32_t> class BoolArray {
}

/**
* Computes the logical xor and return the result.
* The current bitmaps is unchanged.
*/
* Computes the logical xor and return the result.
* The current bitmaps is unchanged.
*/
BoolArray logicalxor(const BoolArray &a) const {
BoolArray answer;
logicalxor(a, answer);
Expand All @@ -319,9 +319,9 @@ template <class uword = uint32_t> class BoolArray {
}

/**
* Computes the logical not and return the result.
* The current bitmaps is unchanged.
*/
* Computes the logical not and return the result.
* The current bitmaps is unchanged.
*/
BoolArray logicalandnot() const {
BoolArray answer;
logicalnot(answer);
Expand Down Expand Up @@ -366,8 +366,8 @@ template <class uword = uint32_t> class BoolArray {
padWithZeroes(a.sizeinbits);
}
/**
* Make sure the current bitmap has the size of the provided bitmap.
*/
* Make sure the current bitmap has the size of the provided bitmap.
*/
void setToSize(const BoolArray &a) {
sizeinbits = a.sizeinbits;
buffer.resize(a.buffer.size());
Expand Down Expand Up @@ -434,7 +434,7 @@ template <class uword = uint32_t> class BoolArray {
void clearBogusBits() {
if ((sizeinbits % wordinbits) != 0) {
const uword maskbogus =
(static_cast<uword>(1) << (sizeinbits % wordinbits)) - 1;
static_cast<uword>((static_cast<uword>(1) << (sizeinbits % wordinbits)) - 1);
buffer[buffer.size() - 1] &= maskbogus;
}
}
Expand Down Expand Up @@ -484,5 +484,5 @@ template <class uword> void BoolArray<uword>::append(const BoolArray &a) {
}
sizeinbits += a.sizeinbits;
}

} // namespace ewah
#endif
Loading

0 comments on commit 49c7bea

Please sign in to comment.