MCPcopy Create free account
hub / github.com/chen3feng/toft / DoLeftShift

Method DoLeftShift

container/bitmap.cpp:153–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153void BitmapBase::DoLeftShift(WordType* words, uint64_t num_bits, size_t shift)
154{
155 const size_t last_word_index = shift / kBitsPerWord;
156 const size_t tail_bits = shift % kBitsPerWord;
157 const size_t word_size = WordSizeOfBits(num_bits);
158
159 if (tail_bits == 0)
160 {
161 for (size_t n = word_size - 1; n >= last_word_index; --n)
162 words[n] = words[n - last_word_index];
163 }
164 else
165 {
166 const size_t sub_offset = kBitsPerWord - tail_bits;
167 for (size_t n = word_size - 1; n > last_word_index; --n)
168 words[n] = ((words[n - last_word_index] << tail_bits)
169 | (words[n - last_word_index - 1] >> sub_offset));
170 words[last_word_index] = words[0] << tail_bits;
171 }
172
173 std::fill(words, words + last_word_index, static_cast<WordType>(0));
174 MaskOffTailBits(words, num_bits);
175}
176
177void BitmapBase::DoRightShift(WordType* words, uint64_t word_size, size_t shift)
178{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected