Function operator+=

Synopsis

#include <include/EASTL/bitvector.h>

bitvector_const_iterator & operator+=(difference_type dist)

Description

No description yet.

Source

Lines 459-489 in include/EASTL/bitvector.h. Line 121 in include/EASTL/bitvector.h.

template <typename Element>
bitvector_const_iterator<Element>&
bitvector_const_iterator<Element>::operator+=(difference_type n)
{
    n += mReference.mnBitIndex;
    if(n >= difference_type(0))
    {
        mReference.mpBitWord  += n / kBitCount;
        mReference.mnBitIndex  = (size_type)(n % kBitCount);
    }
    else
    {
        // backwards is tricky
        // figure out how many full words backwards we need to move
        // n = [-1..-32] => 1
        // n = [-33..-64] => 2
        const size_type backwards = (size_type)(-n + kBitCount - 1);
        mReference.mpBitWord -= backwards / kBitCount;
        // -1 => 31; backwards = 32; 31 - (backwards % 32) = 31
        // -2 => 30; backwards = 33; 31 - (backwards % 32) = 30
        // -3 => 29; backwards = 34
        // ..
        // -32 => 0; backwards = 63; 31 - (backwards % 32) = 0
        // -33 => 31; backwards = 64; 31 - (backwards % 32) = 31
        mReference.mnBitIndex = (kBitCount - 1) - (backwards % kBitCount);
    }
    return *this;
}





Add Discussion as Guest

Log in