NCBI C++ ToolKit
Public Types | Public Member Functions | Protected Types | Private Attributes | List of all members
bm::sparse_vector< Val, BV >::back_insert_iterator Class Reference

Search Toolkit Book for bm::sparse_vector::back_insert_iterator

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

#include <util/bitset/bmsparsevec.h>

+ Collaboration diagram for bm::sparse_vector< Val, BV >::back_insert_iterator:

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::unsigned_value_type unsigned_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

void operator= (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...
 
bool flush ()
 flush the accumulated buffer More...
 
bvector_typeget_null_bvect () const noexcept
 Get access to not-null vector. More...
 
void add_value_no_null (value_type v)
 add value to the buffer without changing the NULL vector More...
 
void disable_set_null () noexcept
 Reconfigure back inserter not to touch the NULL vector. More...
 
Construction and assignment
 back_insert_iterator ()
 
 back_insert_iterator (sparse_vector_type *sv)
 
 back_insert_iterator (const back_insert_iterator &bi)
 
void operator= (const back_insert_iterator &bi)
 
 back_insert_iterator (back_insert_iterator &&bi) noexcept
 move constructor More...
 
void operator= (back_insert_iterator &&bi) noexcept
 move assignment More...
 
 ~back_insert_iterator ()
 

Protected Types

typedef bvector_type::block_idx_type block_idx_type
 

Private Attributes

buffer_type buffer_
 
bm::sparse_vector< Val, BV > * sv_ = 0
 !< value buffer More...
 
bvector_typebv_null_ = 0
 !< pointer on the parent vector More...
 
unsigned_value_typebuf_ptr_ = 0
 !< not NULL vector pointer More...
 
bool set_not_null_ = true
 !< position in the buffer More...
 
block_idx_type prev_nb_ = 0
 
bvector_type::optmode opt_mode_ = bvector_type::opt_compress
 !< previous block added 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 per vector at a 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 255 of file bmsparsevec.h.

Member Typedef Documentation

◆ allocator_pool_type

Definition at line 268 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 267 of file bmsparsevec.h.

◆ block_idx_type

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

Definition at line 358 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 269 of file bmsparsevec.h.

◆ bvector_type

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

Definition at line 266 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 271 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 259 of file bmsparsevec.h.

◆ pointer

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

Definition at line 272 of file bmsparsevec.h.

◆ reference

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

Definition at line 273 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 265 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 261 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 262 of file bmsparsevec.h.

◆ unsigned_value_type

Definition at line 264 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 263 of file bmsparsevec.h.

Constructor & Destructor Documentation

◆ back_insert_iterator() [1/4]

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

Definition at line 2461 of file bmsparsevec.h.

◆ back_insert_iterator() [2/4]

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

◆ back_insert_iterator() [3/4]

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

◆ back_insert_iterator() [4/4]

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

move constructor

◆ ~back_insert_iterator()

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

Definition at line 2517 of file bmsparsevec.h.

Member Function Documentation

◆ add()

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

add value to the container

Definition at line 2525 of file bmsparsevec.h.

References BM_ASSERT.

◆ add_null() [1/2]

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

add NULL (no-value) to the container

Definition at line 2567 of file bmsparsevec.h.

References BM_ASSERT.

Referenced by TestSparseVector(), TestSparseVectorInserter(), and TestSparseVectorScan().

◆ 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_no_null()

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

add value to the buffer without changing the NULL vector

Parameters
v- value to push back

Definition at line 2547 of file bmsparsevec.h.

References BM_ASSERT, bm::sparse_vector< Val, BV >::n_buf_size, and bm::base_sparse_vector< Val, BV, 1 >::s2u().

◆ disable_set_null()

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

Reconfigure back inserter not to touch the NULL vector.

Definition at line 354 of file bmsparsevec.h.

◆ empty()

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

return true if insertion buffer is empty

Definition at line 2594 of file bmsparsevec.h.

Referenced by TestSparseVectorInserter().

◆ flush()

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

flush the accumulated buffer

Returns
true if actually flushed (back inserter had data to flush)

Definition at line 2602 of file bmsparsevec.h.

References arr, and bm::set_block_shift.

Referenced by TestSignedSparseVector(), TestSignedSparseVectorScanGT(), TestSparseVector(), TestSparseVectorGatherDecode(), TestSparseVectorInserter(), and TestSparseVectorScanGT().

◆ get_null_bvect()

template<class Val , class BV >
bvector_type* bm::sparse_vector< Val, BV >::back_insert_iterator::get_null_bvect ( ) const
inlinenoexcept

Get access to not-null vector.

Definition at line 343 of file bmsparsevec.h.

◆ operator*()

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

noop

Definition at line 312 of file bmsparsevec.h.

◆ operator++() [1/2]

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

noop

Definition at line 314 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 316 of file bmsparsevec.h.

◆ operator=() [1/3]

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

move assignment

Definition at line 295 of file bmsparsevec.h.

◆ operator=() [2/3]

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

Definition at line 283 of file bmsparsevec.h.

◆ operator=() [3/3]

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

push value to the vector

Definition at line 310 of file bmsparsevec.h.

Member Data Documentation

◆ buf_ptr_

template<class Val , class BV >
unsigned_value_type* bm::sparse_vector< Val, BV >::back_insert_iterator::buf_ptr_ = 0
private

!< not NULL vector pointer

Definition at line 364 of file bmsparsevec.h.

◆ buffer_

template<class Val , class BV >
buffer_type bm::sparse_vector< Val, BV >::back_insert_iterator::buffer_
private

Definition at line 361 of file bmsparsevec.h.

◆ bv_null_

template<class Val , class BV >
bvector_type* bm::sparse_vector< Val, BV >::back_insert_iterator::bv_null_ = 0
private

!< pointer on the parent vector

Definition at line 363 of file bmsparsevec.h.

◆ opt_mode_

template<class Val , class BV >
bvector_type::optmode bm::sparse_vector< Val, BV >::back_insert_iterator::opt_mode_ = bvector_type::opt_compress
private

!< previous block added

Definition at line 369 of file bmsparsevec.h.

◆ prev_nb_

template<class Val , class BV >
block_idx_type bm::sparse_vector< Val, BV >::back_insert_iterator::prev_nb_ = 0
private

Definition at line 367 of file bmsparsevec.h.

◆ set_not_null_

template<class Val , class BV >
bool bm::sparse_vector< Val, BV >::back_insert_iterator::set_not_null_ = true
private

!< position in the buffer

Definition at line 365 of file bmsparsevec.h.

◆ sv_

template<class Val , class BV >
bm::sparse_vector<Val, BV>* bm::sparse_vector< Val, BV >::back_insert_iterator::sv_ = 0
private

!< value buffer

Definition at line 362 of file bmsparsevec.h.


The documentation for this class was generated from the following file:
Modified on Tue May 21 10:54:17 2024 by modify_doxy.py rev. 669887