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

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

#include <bmstrsparsevec.h>

Collaboration diagram for bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator:
Collaboration graph
[legend]

Public Types

typedef std::output_iterator_tag iterator_category
 
typedef str_sparse_vector< CharType, BV, 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 () BMNOEXCEPT
 
 back_insert_iterator (str_sparse_vector_type *sv) BMNOEXCEPT
  More...
 
 back_insert_iterator (const back_insert_iterator &bi) BMNOEXCEPT
 
back_insert_iteratoroperator= (const back_insert_iterator &bi)
  More...
 
 ~back_insert_iterator ()
 
void set_optimize (typename bvector_type::optmode opt_mode) BMNOEXCEPT
 Set optimization on load option (deafult: false) More...
 
void set_remap (bool flag) BMNOEXCEPT
 Method to configure back inserter to collect statistics on optimal character codes. More...
 
unsigned get_remap () const BMNOEXCEPT
 Get curent remap state flags. More...
 
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...
 
void flush ()
 flush the accumulated buffer. More...
 
const octet_freq_matrix_typeget_octet_matrix () const noexcept
 Get octet frequence matrix. More...
 

Protected Types

typedef bvector_type::block_idx_type block_idx_type
 

Protected Member Functions

bool empty () const BMNOEXCEPT
 return true if insertion buffer is empty More...
 
void add_value (const value_type *v)
 add value to the buffer without changing the NULL vector More...
 
void add_remap_stat (const value_type *v)
 account new value as remap statistics More...
 
void flush_impl ()
  More...
 

Protected Attributes

str_sparse_vector_typesv_
  More...
 
bvector_typebv_null_
 !< pointer on the parent vector More...
 
buffer_matrix_type buf_matrix_
 !< not NULL vector pointer More...
 
size_type pos_in_buf_
 !< value buffer More...
 
block_idx_type prev_nb_ = 0
 !< buffer position More...
 
bvector_type::optmode opt_mode_ = bvector_type::opt_compress
 !< previous block added More...
 
unsigned remap_flags_ = 0
 target remapping More...
 
octet_freq_matrix_type omatrix_
 octet frequency matrix More...
 

Friends

class str_sparse_vector
 

Detailed Description

template<typename CharType, typename BV, unsigned STR_SIZE>
class bm::str_sparse_vector< CharType, BV, 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 339 of file bmstrsparsevec.h.

Member Function Documentation

◆ add()

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

add value to the container

Definition at line 2699 of file bmstrsparsevec.h.

Referenced by bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::operator=().

◆ add_null() [1/2]

template<class CharType , class BV , unsigned STR_SIZE>
void bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::add_null

add NULL (no-value) to the container

Examples
strsvsample04.cpp, and strsvsample06.cpp.

Definition at line 2718 of file bmstrsparsevec.h.

Referenced by main().

◆ add_null() [2/2]

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

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

◆ add_remap_stat()

template<typename CharType , typename BV , unsigned STR_SIZE>
void bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::add_remap_stat ( const value_type v)
protected

account new value as remap statistics

Definition at line 2738 of file bmstrsparsevec.h.

References BM_ASSERT, and bm::str_sparse_vector< CharType, BV, STR_SIZE >::remap_flags_.

◆ add_value()

template<typename CharType , typename BV , unsigned STR_SIZE>
void bm::str_sparse_vector< CharType, BV, 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

Definition at line 2778 of file bmstrsparsevec.h.

References BM_ASSERT, bm::str_sparse_vector< CharType, BV, STR_SIZE >::remap_flags_, and bm::str_sparse_vector< CharType, BV, STR_SIZE >::resize().

◆ empty()

template<class CharType , class BV , unsigned STR_SIZE>
bool bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::empty
protected

return true if insertion buffer is empty

Definition at line 2656 of file bmstrsparsevec.h.

◆ flush()

template<class CharType , class BV , unsigned STR_SIZE>
void bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::flush

flush the accumulated buffer.

It is important to call flush at the end, before destruction of the inserter. Flush may throw exceptions, which will be possible to intercept. Otherwise inserter is flushed in the destructor.

Examples
strsvsample02a.cpp, strsvsample03.cpp, and xsample05.cpp.

Definition at line 2665 of file bmstrsparsevec.h.

References bm::str_sparse_vector< CharType, BV, STR_SIZE >::remap_flags_.

Referenced by main().

◆ flush_impl()

template<class CharType , class BV , unsigned STR_SIZE>
void bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::flush_impl
protected

◆ get_octet_matrix()

template<typename CharType , typename BV , unsigned STR_SIZE>
const octet_freq_matrix_type& bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::get_octet_matrix ( ) const
inlinenoexcept

Get octet frequence matrix.

Definition at line 433 of file bmstrsparsevec.h.

References bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::omatrix_.

◆ get_remap()

template<typename CharType , typename BV , unsigned STR_SIZE>
unsigned bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::get_remap ( ) const
inline

Get curent remap state flags.

Definition at line 392 of file bmstrsparsevec.h.

References bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::remap_flags_.

◆ operator*()

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

noop

Definition at line 407 of file bmstrsparsevec.h.

◆ operator++() [1/2]

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

noop

Definition at line 409 of file bmstrsparsevec.h.

◆ operator++() [2/2]

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

noop

Definition at line 411 of file bmstrsparsevec.h.

◆ operator=() [1/3]

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

◆ operator=() [2/3]

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

push value to the vector

Definition at line 401 of file bmstrsparsevec.h.

References bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::add().

◆ operator=() [3/3]

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

push value to the vector

Definition at line 395 of file bmstrsparsevec.h.

References bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::add().

◆ set_optimize()

template<typename CharType , typename BV , unsigned STR_SIZE>
void bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::set_optimize ( typename bvector_type::optmode  opt_mode)
inline

Set optimization on load option (deafult: false)

Definition at line 376 of file bmstrsparsevec.h.

References bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::opt_mode_.

◆ set_remap()

template<typename CharType , typename BV , unsigned STR_SIZE>
void bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::set_remap ( bool  flag)
inline

Method to configure back inserter to collect statistics on optimal character codes.

This methos makes back inserter slower, but can be used to accelerate later remap() of the sparse vector. Use flush at the end to apply the remapping. By default inserter does not collect additional statistics.

Important! You should NOT use intermediate flush if you set remapping!

See also
flush
Examples
strsvsample03.cpp.

Definition at line 389 of file bmstrsparsevec.h.

References bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::remap_flags_.

Referenced by main().

Field Documentation

◆ buf_matrix_

template<typename CharType , typename BV , unsigned STR_SIZE>
buffer_matrix_type bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::buf_matrix_
protected

!< not NULL vector pointer

Definition at line 466 of file bmstrsparsevec.h.

Referenced by bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::operator=().

◆ bv_null_

template<typename CharType , typename BV , unsigned STR_SIZE>
bvector_type* bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::bv_null_
protected

!< pointer on the parent vector

Definition at line 465 of file bmstrsparsevec.h.

◆ omatrix_

template<typename CharType , typename BV , unsigned STR_SIZE>
octet_freq_matrix_type bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::omatrix_
protected

◆ opt_mode_

template<typename CharType , typename BV , unsigned STR_SIZE>
bvector_type::optmode bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::opt_mode_ = bvector_type::opt_compress
protected

!< previous block added

Definition at line 470 of file bmstrsparsevec.h.

Referenced by bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::set_optimize().

◆ pos_in_buf_

template<typename CharType , typename BV , unsigned STR_SIZE>
size_type bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::pos_in_buf_
protected

!< value buffer

Definition at line 467 of file bmstrsparsevec.h.

◆ prev_nb_

template<typename CharType , typename BV , unsigned STR_SIZE>
block_idx_type bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::prev_nb_ = 0
protected

!< buffer position

Definition at line 468 of file bmstrsparsevec.h.

◆ remap_flags_

template<typename CharType , typename BV , unsigned STR_SIZE>
unsigned bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::remap_flags_ = 0
protected

◆ sv_

template<typename CharType , typename BV , unsigned STR_SIZE>
str_sparse_vector_type* bm::str_sparse_vector< CharType, BV, STR_SIZE >::back_insert_iterator::sv_
protected

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