Function insert

Summary

#include <include/EASTL/bitvector.h>

(1) iterator insert(const_iterator position, value_type value)

(2) void insert(const_iterator position, size_type n, value_type value)

Function overload

Synopsis

#include <include/EASTL/bitvector.h>

iterator insert(const_iterator position, value_type value)

Description

No description yet.

Source

Lines 1159-1179 in include/EASTL/bitvector.h. Line 313 in include/EASTL/bitvector.h.

template <typename Allocator, typename Element, typename Container>
typename bitvector<Allocator, Element, Container>::iterator
bitvector<Allocator, Element, Container>::insert(const_iterator position, value_type value)
{
    iterator iPosition(position.get_reference_type()); // This is just a non-const version of position.
    #if EASTL_ASSERT_ENABLED
        if(EASTL_UNLIKELY(validate_iterator(iPosition) & eastl::isf_valid) == 0)
            EASTL_FAIL_MSG("bitvector::insert -- invalid iterator");
    #endif
    // Save because we might reallocate
    const typename iterator::difference_type n = iPosition - begin();
    push_back();
    iPosition = begin() + n;
    MoveBits(iPosition, --end(), ++iterator(iPosition));
    *iPosition = value;
    return iPosition;
}

Synopsis

#include <include/EASTL/bitvector.h>

void insert(const_iterator position, size_type n, value_type value)

Description

No description yet.

Source

Lines 1182-1206 in include/EASTL/bitvector.h. Line 314 in include/EASTL/bitvector.h.

template <typename Allocator, typename Element, typename Container>
void bitvector<Allocator, Element, Container>::insert(const_iterator position, size_type n, value_type value)
{
    iterator iPosition(position.get_reference_type()); // This is just a non-const version of position.
    #if EASTL_ASSERT_ENABLED
        if(EASTL_UNLIKELY(validate_iterator(iPosition) & eastl::isf_valid) == 0)
            EASTL_FAIL_MSG("bitvector::insert -- invalid iterator");
    #endif
    // Save because we might reallocate.
    const typename iterator::difference_type p = iPosition - begin();
    resize(size() + n);
    iPosition = begin() + p;
    iterator insert_end = iPosition + n;
    MoveBits(iPosition, end() - n, insert_end);
    // To do: Optimize this to word-at-a-time for large inserts
    while(iPosition != insert_end)
    {
        *iPosition = value;
        ++iPosition;
    }
}





Add Discussion as Guest

Log in