BitMagic-C++
Public Types | Public Member Functions | Protected Member Functions
bm::sparse_vector< Val, BV >::back_insert_iterator Class Reference

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

#include <bmsparsevec.h>

Public Types

typedef std::output_iterator_tag iterator_category
 
typedef sparse_vector< Val, BV > sparse_vector_type
 
typedef sparse_vector_typesparse_vector_type_ptr
 
typedef sparse_vector_type::value_type value_type
 
typedef sparse_vector_type::size_type size_type
 
typedef sparse_vector_type::bvector_type bvector_type
 
typedef bvector_type::allocator_type allocator_type
 
typedef bvector_type::allocator_type::allocator_pool_type allocator_pool_type
 
typedef bm::byte_buffer< allocator_typebuffer_type
 
typedef void difference_type
 
typedef void pointer
 
typedef void reference
 

Public Member Functions

 back_insert_iterator ()
 
 back_insert_iterator (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= (value_type 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 (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 (value_type v)
 add value to the buffer without changing the NULL vector More...
 

Detailed Description

template<class Val, class BV>
class bm::sparse_vector< Val, BV >::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.

Definition at line 251 of file bmsparsevec.h.

Member Typedef Documentation

◆ allocator_pool_type

Definition at line 263 of file bmsparsevec.h.

◆ allocator_type

template<class Val, class BV>
typedef bvector_type::allocator_type bm::sparse_vector< Val, BV >::back_insert_iterator::allocator_type

Definition at line 262 of file bmsparsevec.h.

◆ buffer_type

template<class Val, class BV>
typedef bm::byte_buffer<allocator_type> bm::sparse_vector< Val, BV >::back_insert_iterator::buffer_type

Definition at line 264 of file bmsparsevec.h.

◆ bvector_type

Definition at line 261 of file bmsparsevec.h.

◆ difference_type

template<class Val, class BV>
typedef void bm::sparse_vector< Val, BV >::back_insert_iterator::difference_type

Definition at line 266 of file bmsparsevec.h.

◆ iterator_category

template<class Val, class BV>
typedef std::output_iterator_tag bm::sparse_vector< Val, BV >::back_insert_iterator::iterator_category

Definition at line 255 of file bmsparsevec.h.

◆ pointer

template<class Val, class BV>
typedef void bm::sparse_vector< Val, BV >::back_insert_iterator::pointer

Definition at line 267 of file bmsparsevec.h.

◆ reference

template<class Val, class BV>
typedef void bm::sparse_vector< Val, BV >::back_insert_iterator::reference

Definition at line 268 of file bmsparsevec.h.

◆ size_type

template<class Val, class BV>
typedef sparse_vector_type::size_type bm::sparse_vector< Val, BV >::back_insert_iterator::size_type

Definition at line 260 of file bmsparsevec.h.

◆ sparse_vector_type

template<class Val, class BV>
typedef sparse_vector<Val, BV> bm::sparse_vector< Val, BV >::back_insert_iterator::sparse_vector_type

Definition at line 257 of file bmsparsevec.h.

◆ sparse_vector_type_ptr

template<class Val, class BV>
typedef sparse_vector_type* bm::sparse_vector< Val, BV >::back_insert_iterator::sparse_vector_type_ptr

Definition at line 258 of file bmsparsevec.h.

◆ value_type

template<class Val, class BV>
typedef sparse_vector_type::value_type bm::sparse_vector< Val, BV >::back_insert_iterator::value_type

Definition at line 259 of file bmsparsevec.h.

Constructor & Destructor Documentation

◆ back_insert_iterator() [1/3]

template<class Val , class BV >
bm::sparse_vector< Val, BV >::back_insert_iterator::back_insert_iterator ( )

◆ back_insert_iterator() [2/3]

template<class Val, class BV>
bm::sparse_vector< Val, BV >::back_insert_iterator::back_insert_iterator ( sparse_vector_type sv)

◆ back_insert_iterator() [3/3]

template<class Val, class BV>
bm::sparse_vector< Val, BV >::back_insert_iterator::back_insert_iterator ( const back_insert_iterator bi)

◆ ~back_insert_iterator()

template<class Val , class BV >
bm::sparse_vector< Val, BV >::back_insert_iterator::~back_insert_iterator ( )

Member Function Documentation

◆ add()

template<class Val, class BV>
void bm::sparse_vector< Val, BV >::back_insert_iterator::add ( value_type  v)

◆ add_null() [1/2]

template<class Val , class BV >
void bm::sparse_vector< Val, BV >::back_insert_iterator::add_null ( )

◆ add_null() [2/2]

template<class Val, class BV>
void bm::sparse_vector< Val, BV >::back_insert_iterator::add_null ( size_type  count)

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

◆ add_value()

template<class Val, class BV>
sparse_vector< Val, BV >::size_type bm::sparse_vector< Val, BV >::back_insert_iterator::add_value ( 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 2109 of file bmsparsevec.h.

References BM_ASSERT, and bm::sparse_vector< Val, BV >::back_insert_iterator::flush().

Referenced by bm::sparse_vector< Val, BV >::back_insert_iterator::add().

◆ empty()

template<class Val , class BV >
bool bm::sparse_vector< Val, BV >::back_insert_iterator::empty ( ) const

◆ flush()

template<class Val , class BV >
void bm::sparse_vector< Val, BV >::back_insert_iterator::flush ( )

◆ operator*()

template<class Val, class BV>
back_insert_iterator& bm::sparse_vector< Val, BV >::back_insert_iterator::operator* ( )
inline

noop

Definition at line 287 of file bmsparsevec.h.

◆ operator++() [1/2]

template<class Val, class BV>
back_insert_iterator& bm::sparse_vector< Val, BV >::back_insert_iterator::operator++ ( )
inline

noop

Definition at line 289 of file bmsparsevec.h.

◆ operator++() [2/2]

template<class Val, class BV>
back_insert_iterator& bm::sparse_vector< Val, BV >::back_insert_iterator::operator++ ( int  )
inline

noop

Definition at line 291 of file bmsparsevec.h.

References bm::bv_statistics::add(), and bm::sparse_vector< Val, BV >::empty().

◆ operator=() [1/2]

template<class Val, class BV>
back_insert_iterator& bm::sparse_vector< Val, BV >::back_insert_iterator::operator= ( const back_insert_iterator bi)
inline

◆ operator=() [2/2]

template<class Val, class BV>
back_insert_iterator& bm::sparse_vector< Val, BV >::back_insert_iterator::operator= ( value_type  v)
inline

push value to the vector

Definition at line 285 of file bmsparsevec.h.

References bm::bv_statistics::add().


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