Function DoFindPrev

Synopsis

#include <include/EASTL/bitset.h>

size_type DoFindPrev(size_type last_find) const

Description

No description yet.

Source

Lines 1060-1089 in include/EASTL/bitset.h. Line 145 in include/EASTL/bitset.h.

template <size_t NW, typename WordType>
inline typename BitsetBase<NW, WordType>::size_type 
BitsetBase<NW, WordType>::DoFindPrev(size_type last_find) const
{
    if(last_find > 0)
    {
        // Set initial state based on last find.
        size_type word_index = static_cast<size_type>(last_find >> kBitsPerWordShift);
        size_type bit_index  = static_cast<size_type>(last_find  & kBitsPerWordMask);
        // Mask off subsequent bits of the word so our search becomes a "find last".
        word_type mask      = (~static_cast<word_type>(0) >> (kBitsPerWord - 1 - bit_index)) >> 1; // We do two shifts here because many CPUs ignore requests to shift 32 bit integers by 32 bits, which could be the case above.
        word_type this_word = mWord[word_index] & mask;
        for(;;)
        {
            const size_type lbiw = GetLastBit(this_word);
            if(lbiw != kBitsPerWord)
                return (word_index * kBitsPerWord) + lbiw;
            if(word_index > 0)
                this_word = mWord[--word_index];
            else
                break;
        }
    }
    return (size_type)NW * kBitsPerWord;
}





Add Discussion as Guest

Log in