Function DoFindNext

Synopsis

#include <include/EASTL/bitset.h>

size_type DoFindNext(size_type last_find) const

Description

No description yet.

Source

Lines 1004-1036 in include/EASTL/bitset.h. Line 324 in include/EASTL/bitset.h.

template <size_t NW, typename WordType>
inline typename BitsetBase<NW, WordType>::size_type 
BitsetBase<NW, WordType>::DoFindNext(size_type last_find) const
{
    // Start looking from the next bit.
    ++last_find;
    // 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);
    // To do: There probably is a more elegant way to write looping below.
    if(word_index < NW)
    {
        // Mask off previous bits of the word so our search becomes a "find first".
        word_type this_word = mWord[word_index] & (~static_cast<word_type>(0) << bit_index);
        for(;;)
        {
            const size_type fbiw = GetFirstBit(this_word);
            if(fbiw != kBitsPerWord)
                return (word_index * kBitsPerWord) + fbiw;
            if(++word_index < NW)
                this_word = mWord[word_index];
            else
                break;
        }
    }
    return (size_type)NW * kBitsPerWord;
}





Add Discussion as Guest

Log in