diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /util/generic/bitops.cpp | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/generic/bitops.cpp')
-rw-r--r-- | util/generic/bitops.cpp | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/util/generic/bitops.cpp b/util/generic/bitops.cpp new file mode 100644 index 0000000000..db5667a21f --- /dev/null +++ b/util/generic/bitops.cpp @@ -0,0 +1,141 @@ +#include "bitops.h" + +namespace NBitOps { + namespace NPrivate { + const ui64 WORD_MASK[] = { + 0x0000000000000000ULL, + 0x0000000000000001ULL, + 0x0000000000000003ULL, + 0x0000000000000007ULL, + 0x000000000000000FULL, + 0x000000000000001FULL, + 0x000000000000003FULL, + 0x000000000000007FULL, + 0x00000000000000FFULL, + 0x00000000000001FFULL, + 0x00000000000003FFULL, + 0x00000000000007FFULL, + 0x0000000000000FFFULL, + 0x0000000000001FFFULL, + 0x0000000000003FFFULL, + 0x0000000000007FFFULL, + 0x000000000000FFFFULL, + 0x000000000001FFFFULL, + 0x000000000003FFFFULL, + 0x000000000007FFFFULL, + 0x00000000000FFFFFULL, + 0x00000000001FFFFFULL, + 0x00000000003FFFFFULL, + 0x00000000007FFFFFULL, + 0x0000000000FFFFFFULL, + 0x0000000001FFFFFFULL, + 0x0000000003FFFFFFULL, + 0x0000000007FFFFFFULL, + 0x000000000FFFFFFFULL, + 0x000000001FFFFFFFULL, + 0x000000003FFFFFFFULL, + 0x000000007FFFFFFFULL, + 0x00000000FFFFFFFFULL, + 0x00000001FFFFFFFFULL, + 0x00000003FFFFFFFFULL, + 0x00000007FFFFFFFFULL, + 0x0000000FFFFFFFFFULL, + 0x0000001FFFFFFFFFULL, + 0x0000003FFFFFFFFFULL, + 0x0000007FFFFFFFFFULL, + 0x000000FFFFFFFFFFULL, + 0x000001FFFFFFFFFFULL, + 0x000003FFFFFFFFFFULL, + 0x000007FFFFFFFFFFULL, + 0x00000FFFFFFFFFFFULL, + 0x00001FFFFFFFFFFFULL, + 0x00003FFFFFFFFFFFULL, + 0x00007FFFFFFFFFFFULL, + 0x0000FFFFFFFFFFFFULL, + 0x0001FFFFFFFFFFFFULL, + 0x0003FFFFFFFFFFFFULL, + 0x0007FFFFFFFFFFFFULL, + 0x000FFFFFFFFFFFFFULL, + 0x001FFFFFFFFFFFFFULL, + 0x003FFFFFFFFFFFFFULL, + 0x007FFFFFFFFFFFFFULL, + 0x00FFFFFFFFFFFFFFULL, + 0x01FFFFFFFFFFFFFFULL, + 0x03FFFFFFFFFFFFFFULL, + 0x07FFFFFFFFFFFFFFULL, + 0x0FFFFFFFFFFFFFFFULL, + 0x1FFFFFFFFFFFFFFFULL, + 0x3FFFFFFFFFFFFFFFULL, + 0x7FFFFFFFFFFFFFFFULL, + 0xFFFFFFFFFFFFFFFFULL, + }; + + const ui64 INVERSE_WORD_MASK[] = { + ~0x0000000000000000ULL, + ~0x0000000000000001ULL, + ~0x0000000000000003ULL, + ~0x0000000000000007ULL, + ~0x000000000000000FULL, + ~0x000000000000001FULL, + ~0x000000000000003FULL, + ~0x000000000000007FULL, + ~0x00000000000000FFULL, + ~0x00000000000001FFULL, + ~0x00000000000003FFULL, + ~0x00000000000007FFULL, + ~0x0000000000000FFFULL, + ~0x0000000000001FFFULL, + ~0x0000000000003FFFULL, + ~0x0000000000007FFFULL, + ~0x000000000000FFFFULL, + ~0x000000000001FFFFULL, + ~0x000000000003FFFFULL, + ~0x000000000007FFFFULL, + ~0x00000000000FFFFFULL, + ~0x00000000001FFFFFULL, + ~0x00000000003FFFFFULL, + ~0x00000000007FFFFFULL, + ~0x0000000000FFFFFFULL, + ~0x0000000001FFFFFFULL, + ~0x0000000003FFFFFFULL, + ~0x0000000007FFFFFFULL, + ~0x000000000FFFFFFFULL, + ~0x000000001FFFFFFFULL, + ~0x000000003FFFFFFFULL, + ~0x000000007FFFFFFFULL, + ~0x00000000FFFFFFFFULL, + ~0x00000001FFFFFFFFULL, + ~0x00000003FFFFFFFFULL, + ~0x00000007FFFFFFFFULL, + ~0x0000000FFFFFFFFFULL, + ~0x0000001FFFFFFFFFULL, + ~0x0000003FFFFFFFFFULL, + ~0x0000007FFFFFFFFFULL, + ~0x000000FFFFFFFFFFULL, + ~0x000001FFFFFFFFFFULL, + ~0x000003FFFFFFFFFFULL, + ~0x000007FFFFFFFFFFULL, + ~0x00000FFFFFFFFFFFULL, + ~0x00001FFFFFFFFFFFULL, + ~0x00003FFFFFFFFFFFULL, + ~0x00007FFFFFFFFFFFULL, + ~0x0000FFFFFFFFFFFFULL, + ~0x0001FFFFFFFFFFFFULL, + ~0x0003FFFFFFFFFFFFULL, + ~0x0007FFFFFFFFFFFFULL, + ~0x000FFFFFFFFFFFFFULL, + ~0x001FFFFFFFFFFFFFULL, + ~0x003FFFFFFFFFFFFFULL, + ~0x007FFFFFFFFFFFFFULL, + ~0x00FFFFFFFFFFFFFFULL, + ~0x01FFFFFFFFFFFFFFULL, + ~0x03FFFFFFFFFFFFFFULL, + ~0x07FFFFFFFFFFFFFFULL, + ~0x0FFFFFFFFFFFFFFFULL, + ~0x1FFFFFFFFFFFFFFFULL, + ~0x3FFFFFFFFFFFFFFFULL, + ~0x7FFFFFFFFFFFFFFFULL, + ~0xFFFFFFFFFFFFFFFFULL, + }; + } +} |