aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/containers/bitseq/traits.h
diff options
context:
space:
mode:
authorIvan Komarov <Ivan.Komarov@dfyz.info>2022-02-10 16:46:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:49 +0300
commit59aca5c5180c31691884667783dc966eb99d743a (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /library/cpp/containers/bitseq/traits.h
parent4de97ab2fe437cbe83e4c63234e809ddd5ac34f2 (diff)
downloadydb-59aca5c5180c31691884667783dc966eb99d743a.tar.gz
Restoring authorship annotation for Ivan Komarov <Ivan.Komarov@dfyz.info>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/containers/bitseq/traits.h')
-rw-r--r--library/cpp/containers/bitseq/traits.h40
1 files changed, 20 insertions, 20 deletions
diff --git a/library/cpp/containers/bitseq/traits.h b/library/cpp/containers/bitseq/traits.h
index 99047363de..2330b1b4f2 100644
--- a/library/cpp/containers/bitseq/traits.h
+++ b/library/cpp/containers/bitseq/traits.h
@@ -2,7 +2,7 @@
#include <util/generic/bitops.h>
#include <util/generic/typetraits.h>
-#include <util/system/yassert.h>
+#include <util/system/yassert.h>
template <typename TWord>
struct TBitSeqTraits {
@@ -25,25 +25,25 @@ struct TBitSeqTraits {
return (bits + NumBits - 1) >> DivShift;
}
- static bool Test(const TWord* data, ui64 pos, ui64 size) {
- Y_ASSERT(pos < size);
- return data[pos >> DivShift] & BitMask(pos & ModMask);
- }
-
- static TWord Get(const TWord* data, ui64 pos, ui8 width, TWord mask, ui64 size) {
- if (!width)
- return 0;
- Y_ASSERT((pos + width) <= size);
- size_t word = pos >> DivShift;
- TWord shift1 = pos & ModMask;
- TWord shift2 = NumBits - shift1;
- TWord res = data[word] >> shift1 & mask;
- if (shift2 < width) {
- res |= data[word + 1] << shift2 & mask;
- }
- return res;
- }
-
+ static bool Test(const TWord* data, ui64 pos, ui64 size) {
+ Y_ASSERT(pos < size);
+ return data[pos >> DivShift] & BitMask(pos & ModMask);
+ }
+
+ static TWord Get(const TWord* data, ui64 pos, ui8 width, TWord mask, ui64 size) {
+ if (!width)
+ return 0;
+ Y_ASSERT((pos + width) <= size);
+ size_t word = pos >> DivShift;
+ TWord shift1 = pos & ModMask;
+ TWord shift2 = NumBits - shift1;
+ TWord res = data[word] >> shift1 & mask;
+ if (shift2 < width) {
+ res |= data[word + 1] << shift2 & mask;
+ }
+ return res;
+ }
+
static_assert(std::is_unsigned<TWord>::value, "Expected std::is_unsigned<T>::value.");
static_assert((NumBits & (NumBits - 1)) == 0, "NumBits should be a power of 2.");
};