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

Method DoRightShift

container/bitmap.cpp:177–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177void BitmapBase::DoRightShift(WordType* words, uint64_t word_size, size_t shift)
178{
179 const size_t last_word_index = shift / kBitsPerWord;
180 const size_t tail_bits = shift % kBitsPerWord;
181 const size_t limit = word_size - last_word_index - 1;
182
183 if (tail_bits == 0)
184 {
185 for (size_t n = 0; n <= limit; ++n)
186 words[n] = words[n + last_word_index];
187 }
188 else
189 {
190 const size_t sub_offset = kBitsPerWord - tail_bits;
191 for (size_t n = 0; n < limit; ++n)
192 words[n] = ((words[n + last_word_index] >> tail_bits)
193 | (words[n + last_word_index + 1] << sub_offset));
194 words[limit] = words[word_size-1] >> tail_bits;
195 }
196
197 std::fill(words + limit + 1, words + word_size, static_cast<WordType>(0));
198}
199
200bool BitmapBase::DoFindFirst(WordType* words, size_t word_size, size_t* result)
201{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected