BitMagic-C++
Public Types | Public Member Functions | Protected Member Functions
bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator Class Reference

Back insert iterator implements buffered insert, faster than generic access assignment. More...

#include <bmstrsparsevec.h>

Public Types

typedef std::output_iterator_tag iterator_category
 
typedef str_sparse_vector< CharType, BV, MAX_STR_SIZE > str_sparse_vector_type
 
typedef str_sparse_vector_typestr_sparse_vector_type_ptr
 
typedef str_sparse_vector_type::value_type value_type
 
typedef str_sparse_vector_type::size_type size_type
 
typedef str_sparse_vector_type::bvector_type bvector_type
 
typedef bvector_type::allocator_type allocator_type
 
typedef allocator_type::allocator_pool_type allocator_pool_type
 
typedef void difference_type
 
typedef void pointer
 
typedef void reference
 

Public Member Functions

 back_insert_iterator ()
 
 back_insert_iterator (str_sparse_vector_type *sv)
 
 back_insert_iterator (const back_insert_iterator &bi)
 
back_insert_iteratoroperator= (const back_insert_iterator &bi)
 
 ~back_insert_iterator ()
 
back_insert_iteratoroperator= (const value_type *v)
 push value to the vector More...
 
template<typename StrType >
back_insert_iteratoroperator= (const StrType &v)
 push value to the vector More...
 
back_insert_iteratoroperator* ()
 noop More...
 
back_insert_iteratoroperator++ ()
 noop More...
 
back_insert_iteratoroperator++ (int)
 noop More...
 
void add (const value_type *v)
 add value to the container More...
 
void add_null ()
 add NULL (no-value) to the container More...
 
void add_null (size_type count)
 add a series of consequitve NULLs (no-value) to the container More...
 
bool empty () const
 return true if insertion buffer is empty More...
 
void flush ()
 flush the accumulated buffer More...
 

Protected Member Functions

size_type add_value (const value_type *v)
 add value to the buffer without changing the NULL vector More...
 

Detailed Description

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
class bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator

Back insert iterator implements buffered insert, faster than generic access assignment.

Limitations for buffered inserter:

  1. Do not use more than one inserter (into one vector) at the same time
  2. Use method flush() at the end to send the rest of accumulated buffer flush is happening automatically on destruction, but if flush produces an exception (for whatever reason) it will be an exception in destructor. As such, explicit flush() is safer way to finilize the sparse vector load.
Examples:
strsvsample03.cpp.

Definition at line 263 of file bmstrsparsevec.h.

Member Typedef Documentation

◆ allocator_pool_type

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
typedef allocator_type::allocator_pool_type bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::allocator_pool_type

Definition at line 275 of file bmstrsparsevec.h.

◆ allocator_type

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
typedef bvector_type::allocator_type bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::allocator_type

Definition at line 274 of file bmstrsparsevec.h.

◆ bvector_type

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
typedef str_sparse_vector_type::bvector_type bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::bvector_type

Definition at line 273 of file bmstrsparsevec.h.

◆ difference_type

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
typedef void bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::difference_type

Definition at line 277 of file bmstrsparsevec.h.

◆ iterator_category

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
typedef std::output_iterator_tag bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::iterator_category

Definition at line 267 of file bmstrsparsevec.h.

◆ pointer

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
typedef void bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::pointer

Definition at line 278 of file bmstrsparsevec.h.

◆ reference

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
typedef void bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::reference

Definition at line 279 of file bmstrsparsevec.h.

◆ size_type

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
typedef str_sparse_vector_type::size_type bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::size_type

Definition at line 272 of file bmstrsparsevec.h.

◆ str_sparse_vector_type

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
typedef str_sparse_vector<CharType, BV, MAX_STR_SIZE> bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::str_sparse_vector_type

Definition at line 269 of file bmstrsparsevec.h.

◆ str_sparse_vector_type_ptr

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
typedef str_sparse_vector_type* bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::str_sparse_vector_type_ptr

Definition at line 270 of file bmstrsparsevec.h.

◆ value_type

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
typedef str_sparse_vector_type::value_type bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::value_type

Definition at line 271 of file bmstrsparsevec.h.

Constructor & Destructor Documentation

◆ back_insert_iterator() [1/3]

template<class CharType , class BV , unsigned MAX_STR_SIZE>
bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::back_insert_iterator ( )

◆ back_insert_iterator() [2/3]

template<class CharType , class BV , unsigned MAX_STR_SIZE>
bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::back_insert_iterator ( str_sparse_vector_type sv)

◆ back_insert_iterator() [3/3]

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::back_insert_iterator ( const back_insert_iterator bi)

◆ ~back_insert_iterator()

template<class CharType , class BV , unsigned MAX_STR_SIZE>
bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::~back_insert_iterator ( )

Member Function Documentation

◆ add()

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
void bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::add ( const value_type v)

◆ add_null() [1/2]

template<class CharType , class BV , unsigned MAX_STR_SIZE>
void bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::add_null ( )

◆ add_null() [2/2]

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
void bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::add_null ( size_type  count)

add a series of consequitve NULLs (no-value) to the container

◆ add_value()

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::size_type bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::add_value ( const value_type v)
protected

add value to the buffer without changing the NULL vector

Parameters
v- value to push back
Returns
index of added value in the internal buffer

Definition at line 1870 of file bmstrsparsevec.h.

References BM_ASSERT, and bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::flush().

Referenced by bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::add(), and bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::add_null().

◆ empty()

template<class CharType , class BV , unsigned MAX_STR_SIZE>
bool bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::empty ( ) const

◆ flush()

template<class CharType , class BV , unsigned MAX_STR_SIZE>
void bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::flush ( )

◆ operator*()

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
back_insert_iterator& bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::operator* ( )
inline

noop

Definition at line 308 of file bmstrsparsevec.h.

◆ operator++() [1/2]

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
back_insert_iterator& bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::operator++ ( )
inline

noop

Definition at line 310 of file bmstrsparsevec.h.

◆ operator++() [2/2]

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
back_insert_iterator& bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::operator++ ( int  )
inline

◆ operator=() [1/3]

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
back_insert_iterator& bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::operator= ( const back_insert_iterator bi)
inline

◆ operator=() [2/3]

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
back_insert_iterator& bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::operator= ( const value_type v)
inline

push value to the vector

Definition at line 296 of file bmstrsparsevec.h.

References bm::bv_statistics::add().

◆ operator=() [3/3]

template<typename CharType, typename BV, unsigned MAX_STR_SIZE>
template<typename StrType >
back_insert_iterator& bm::str_sparse_vector< CharType, BV, MAX_STR_SIZE >::back_insert_iterator::operator= ( const StrType &  v)
inline

push value to the vector

Definition at line 302 of file bmstrsparsevec.h.

References bm::bv_statistics::add().


The documentation for this class was generated from the following file: