mdds
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
mdds::multi_type_vector< _ElemBlockFunc, _EventFunc > Class Template Reference

#include <multi_type_vector.hpp>

Public Types

typedef size_t size_type
 
typedef mdds::mtv::base_element_block element_block_type
 
typedef mdds::mtv::element_t element_category_type
 
typedef _ElemBlockFunc element_block_func
 
typedef _EventFunc event_func
 
typedef detail::mtv::iterator_base< iterator_trait, itr_forward_updateiterator
 
typedef detail::mtv::iterator_base< reverse_iterator_trait, itr_no_updatereverse_iterator
 
typedef detail::mtv::const_iterator_base< const_iterator_trait, itr_forward_update, iteratorconst_iterator
 
typedef detail::mtv::const_iterator_base< const_reverse_iterator_trait, itr_no_update, reverse_iteratorconst_reverse_iterator
 
typedef itr_node value_type
 
typedef std::pair< iterator, size_type > position_type
 
typedef std::pair< const_iterator, size_type > const_position_type
 

Public Member Functions

iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
reverse_iterator rbegin ()
 
reverse_iterator rend ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator crend () const
 
event_funcevent_handler ()
 
const event_funcevent_handler () const
 
 multi_type_vector ()
 
 multi_type_vector (const event_func &hdl)
 
 multi_type_vector (event_func &&hdl)
 
 multi_type_vector (size_type init_size)
 
template<typename _T >
 multi_type_vector (size_type init_size, const _T &value)
 
template<typename _T >
 multi_type_vector (size_type init_size, const _T &it_begin, const _T &it_end)
 
 multi_type_vector (const multi_type_vector &other)
 
 ~multi_type_vector ()
 
template<typename _T >
iterator set (size_type pos, const _T &value)
 
template<typename _T >
iterator set (const iterator &pos_hint, size_type pos, const _T &value)
 
template<typename _T >
iterator set (size_type pos, const _T &it_begin, const _T &it_end)
 
template<typename _T >
iterator set (const iterator &pos_hint, size_type pos, const _T &it_begin, const _T &it_end)
 
template<typename _T >
iterator push_back (const _T &value)
 
iterator push_back_empty ()
 
template<typename _T >
iterator insert (size_type pos, const _T &it_begin, const _T &it_end)
 
template<typename _T >
iterator insert (const iterator &pos_hint, size_type pos, const _T &it_begin, const _T &it_end)
 
template<typename _T >
void get (size_type pos, _T &value) const
 
template<typename _T >
_T get (size_type pos) const
 
template<typename _T >
_T release (size_type pos)
 
template<typename _T >
iterator release (size_type pos, _T &value)
 
template<typename _T >
iterator release (const iterator &pos_hint, size_type pos, _T &value)
 
void release ()
 
iterator release_range (size_type start_pos, size_type end_pos)
 
iterator release_range (const iterator &pos_hint, size_type start_pos, size_type end_pos)
 
position_type position (size_type pos)
 
position_type position (const iterator &pos_hint, size_type pos)
 
const_position_type position (size_type pos) const
 
const_position_type position (const const_iterator &pos_hint, size_type pos) const
 
iterator transfer (size_type start_pos, size_type end_pos, multi_type_vector &dest, size_type dest_pos)
 
iterator transfer (const iterator &pos_hint, size_type start_pos, size_type end_pos, multi_type_vector &dest, size_type dest_pos)
 
mtv::element_t get_type (size_type pos) const
 
bool is_empty (size_type pos) const
 
iterator set_empty (size_type start_pos, size_type end_pos)
 
iterator set_empty (const iterator &pos_hint, size_type start_pos, size_type end_pos)
 
void erase (size_type start_pos, size_type end_pos)
 
iterator insert_empty (size_type pos, size_type length)
 
iterator insert_empty (const iterator &pos_hint, size_type pos, size_type length)
 
void clear ()
 
size_type size () const
 
size_type block_size () const
 
bool empty () const
 
void resize (size_type new_size)
 
void swap (multi_type_vector &other)
 
void swap (size_type start_pos, size_type end_pos, multi_type_vector &other, size_type other_pos)
 
void shrink_to_fit ()
 
bool operator== (const multi_type_vector &other) const
 
bool operator!= (const multi_type_vector &other) const
 
multi_type_vectoroperator= (const multi_type_vector &other)
 

Static Public Member Functions

static position_type next_position (const position_type &pos)
 
static position_type advance_position (const position_type &pos, int steps)
 
static const_position_type next_position (const const_position_type &pos)
 
static const_position_type advance_position (const const_position_type &pos, int steps)
 
static size_type logical_position (const const_position_type &pos)
 
template<typename _Blk >
static _Blk::value_type get (const const_position_type &pos)
 
template<typename _T >
static mtv::element_t get_element_type (const _T &elem)
 

Detailed Description

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
class mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >

Multi-type vector consists of a series of one or more blocks, and each block may either be empty, or stores a series of non-empty elements of identical type. These blocks collectively represent a single logical one-dimensional array that may store elements of different types. It is guaranteed that the block types of neighboring blocks are always different.

Structurally, the primary array stores block instances whose types are of value_type, which in turn consists of the following data members:

See also
mdds::multi_type_vector::value_type

Member Typedef Documentation

◆ event_func

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
typedef _EventFunc mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::event_func

Optional event handler function structure, whose functions get called at specific events. The following events are currently supported:

  • element_block_acquired - this gets called whenever the container acquires a new element block either as a result of a new element block creation or a tranfer of an existing element block from another container.
  • element_block_released - this gets called whenever the container releases an existing element block either because the block gets deleted or gets transferred to another container.
See also
mdds::detail::mtv_event_func for the precise function signatures of the event handler functions.

◆ value_type

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
typedef itr_node mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::value_type

value_type is the type of a block stored in the primary array. It consists of the following data members:

  • type which indicates the block type,
  • position which stores the logical position of the first element of the block,
  • size which stores the logical size of the block, and
  • data which stores the pointer to a secondary array (a.k.a. element block) which stores the actual element values, or nullptr in case the block represents an empty segment.

Constructor & Destructor Documentation

◆ multi_type_vector() [1/7]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::multi_type_vector ( )

Default constructor. It initializes the container with empty size.

◆ multi_type_vector() [2/7]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::multi_type_vector ( const event_func hdl)

Constructor that takes an lvalue reference to an event handler object. The event handler instance will be copy-constructed.

Parameters
hdllvalue reference to an event handler object.

◆ multi_type_vector() [3/7]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::multi_type_vector ( event_func &&  hdl)

Constructor that takes an rvalue reference to an event handler object. The event handler instance will be move-constructed.

Parameters
hdlrvalue reference to an event handler object.

◆ multi_type_vector() [4/7]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::multi_type_vector ( size_type  init_size)

Constructor that takes initial size of the container. When the size specified is greater than 0, it initializes the container with empty elements.

Parameters
init_sizeinitial container size.

◆ multi_type_vector() [5/7]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
template<typename _T >
mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::multi_type_vector ( size_type  init_size,
const _T &  value 
)

Constructor that takes initial size of the container and an element value to initialize the elements to. When the size specified is greater than 0, it initializes the container with elements that are copies of the value specified.

Parameters
init_sizeinitial container size.
valueinitial element value.

◆ multi_type_vector() [6/7]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
template<typename _T >
mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::multi_type_vector ( size_type  init_size,
const _T &  it_begin,
const _T &  it_end 
)

Constructor that takes initial size of the container and begin and end iterator positions that specify a series of elements to initialize the container to. The container will contain copies of the elements specified after this call returns.

Parameters
init_sizeinitial container size.
it_beginiterator that points to the begin position of the values the container is being initialized to.
it_enditerator that points to the end position of the values the container is being initialized to. The end position is not inclusive.

◆ multi_type_vector() [7/7]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::multi_type_vector ( const multi_type_vector< _ElemBlockFunc, _EventFunc > &  other)

Copy constructor.

Parameters
otherother column instance to copy values from.

◆ ~multi_type_vector()

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::~multi_type_vector ( )

Destructor. It deletes all allocated data blocks.

Member Function Documentation

◆ advance_position() [1/2]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
static position_type mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::advance_position ( const position_type &  pos,
int  steps 
)
static

Increment or decrement the position object by specified steps. Caller must ensure the the position object is valid.

Parameters
posposition object.
stepssteps to advance the position object.
Returns
position object that points to the new logical position.

◆ advance_position() [2/2]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
static const_position_type mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::advance_position ( const const_position_type &  pos,
int  steps 
)
static

Increment or decrement the position object by specified steps. Caller must ensure the the position object is valid.

Parameters
posposition object.
stepssteps to advance the position object.
Returns
position object that points to the new logical position.

◆ block_size()

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
size_type mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::block_size ( ) const

Return the current number of blocks in the primary array. Each non-empty block stores a secondary block that stores elements in a contiguous region in memory (element block) and the number of elements it stores. An empty block only stores its logical size and does not store an actual element block.

For instance, if the container stores values of double-precision type at rows 0 to 2, values of std::string type at 3 to 7, and empty values at 8 to 10, it would consist of three blocks: one that stores double values, one that stores std::string values, and one that represents the empty value range in this exact order. In this specific scenario, block_size() returns 3, and size() returns 11.

Returns
current number of blocks in the primary array.

◆ clear()

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
void mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::clear ( )

Clear the content of the container. The size of the container will become zero after calling this method.

◆ empty()

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
bool mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::empty ( ) const

Return whether or not the container is empty.

Returns
true if the container is empty, false otherwise.

◆ erase()

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
void mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::erase ( size_type  start_pos,
size_type  end_pos 
)

Erase elements located between specified start and end positions. The end positions are both inclusive. Those elements originally located after the specified end position will get shifted up after the erasure.

The method will throw an std::out_of_range exception if either the starting or the ending position is outside the current container range.

Calling this method will decrease the size of the container by the length of the erased range.

Parameters
start_posstarting position
end_posending position, inclusive.

◆ get() [1/3]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
template<typename _Blk >
static _Blk::value_type mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::get ( const const_position_type &  pos)
static

Get element value from a position object. The caller must specify the type of block in which the element is expected to be stored.

Parameters
posposition object.
Returns
element value.

◆ get() [2/3]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
template<typename _T >
void mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::get ( size_type  pos,
_T &  value 
) const

Get the value of an element at specified position. The caller must pass a variable of the correct type to store the value.

The method will throw an std::out_of_range exception if the specified position is outside the current container range.

Parameters
posposition of the element value to retrieve.
value(out) variable to store the retrieved value.

◆ get() [3/3]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
template<typename _T >
_T mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::get ( size_type  pos) const

Get the value of an element at specified position. The caller must specify the type of the element as the template parameter e.g. get<double>(1).

The method will throw an std::out_of_range exception if the specified position is outside the current container range.

Parameters
posposition of the element value to retrieve.
Returns
element value.

◆ get_element_type()

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
template<typename _T >
static mtv::element_t mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::get_element_type ( const _T &  elem)
static

Return the numerical identifier that represents passed element.

Parameters
elemelement value.
Returns
numerical identifier representing the element.

◆ get_type()

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
mtv::element_t mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::get_type ( size_type  pos) const

Get the type of an element at specified position.

Parameters
posposition of the element.
Returns
element type.

◆ insert() [1/2]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
template<typename _T >
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::insert ( size_type  pos,
const _T &  it_begin,
const _T &  it_end 
)

Insert multiple values of identical type to a specified position. Existing values that occur at or below the specified position will get shifted after the insertion. No existing values will be overwritten by the inserted values.

The method will throw an std::out_of_range exception if the specified position is outside the current container range.

Calling this method will increase the size of the container by the length of the new values inserted.

Parameters
posposition at which the new values are to be inserted.
it_beginiterator that points to the begin position of the values being inserted.
it_enditerator that points to the end position of the values being inserted.
Returns
iterator position pointing to the block where the value is inserted. When no value insertion occurs because the value set is empty, the end iterator position is returned.

◆ insert() [2/2]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
template<typename _T >
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::insert ( const iterator pos_hint,
size_type  pos,
const _T &  it_begin,
const _T &  it_end 
)

Insert multiple values of identical type to a specified position. Existing values that occur at or below the specified position will get shifted after the insertion. No existing values will be overwritten by the inserted values.

This variant takes an iterator as an additional parameter, which is used as a block position hint to speed up the lookup of the first insertion block. The other variant that doesn't take an iterator always starts the block lookup from the first block, which does not scale well as the block size grows.

This position hint iterator must precede the insertion position to yield any performance benefit.

The caller is responsible for ensuring that the passed iterator is valid. The behavior of this method when passing an invalid iterator is undefined.

The method will throw an std::out_of_range exception if the specified position is outside the current container range.

Calling this method will increase the size of the container by the length of the new values inserted.

Parameters
pos_hintiterator used as a block position hint, to specify which block to start when searching for the right block to insert the value into.
posposition at which the new values are to be inserted.
it_beginiterator that points to the begin position of the values being inserted.
it_enditerator that points to the end position of the values being inserted.
Returns
iterator position pointing to the block where the value is inserted. When no value insertion occurs because the value set is empty, the end iterator position is returned.

◆ insert_empty() [1/2]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::insert_empty ( size_type  pos,
size_type  length 
)

Insert a range of empty elements at specified position. Those elements originally located after the insertion position will get shifted down after the insertion.

The method will throw an std::out_of_range exception if either the specified position is outside the current container range.

Calling this method will increase the size of the container by the length of the inserted empty elements.

Parameters
posposition at which to insert a range of empty elements.
lengthnumber of empty elements to insert.
Returns
iterator position pointing to the block where the empty range is inserted. When no insertion occurs because the length is zero, the end iterator position is returned.

◆ insert_empty() [2/2]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::insert_empty ( const iterator pos_hint,
size_type  pos,
size_type  length 
)

Insert a range of empty elements at specified position. Those elements originally located after the insertion position will get shifted down after the insertion.

This variant takes an iterator as an additional parameter, which is used as a block position hint to speed up the lookup of the block in which to insert the new empty segment. The other variant that doesn't take an iterator always starts the block lookup from the first block, which does not scale well as the block size grows.

This position hint iterator must precede the start position to yield any performance benefit.

The caller is responsible for ensuring that the passed iterator is valid. The behavior of this method when passing an invalid iterator is undefined.

The method will throw an std::out_of_range exception if either the specified position is outside the current container range.

Calling this method will increase the size of the container by the length of the inserted empty elements.

Parameters
pos_hintiterator used as a block position hint, to specify which block to start when searching for the right block in which to insert the empty segment.
posposition at which to insert a range of empty elements.
lengthnumber of empty elements to insert.
Returns
iterator position pointing to the block where the empty range is inserted. When no insertion occurs because the length is zero, the end iterator position is returned.

◆ is_empty()

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
bool mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::is_empty ( size_type  pos) const

Check if element at specified position is empty of not.

The method will throw an std::out_of_range exception if the specified position is outside the current container range.

Parameters
posposition of the element to check.
Returns
true if the element is empty, false otherwise.

◆ logical_position()

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
static size_type mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::logical_position ( const const_position_type &  pos)
static

Extract the logical position from a position object.

Parameters
posposition object.
Returns
logical position of the element that the position object references.

◆ next_position() [1/2]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
static position_type mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::next_position ( const position_type &  pos)
static

Move the position object to the next logical position. Caller must ensure the the position object is valid.

Parameters
posposition object.
Returns
position object that points to the next logical position.

◆ next_position() [2/2]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
static const_position_type mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::next_position ( const const_position_type &  pos)
static

Move the position object to the next logical position. Caller must ensure the the position object is valid.

Parameters
posposition object.
Returns
position object that points to the next logical position.

◆ position() [1/4]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
position_type mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::position ( size_type  pos)

Given the logical position of an element, get the iterator of the block where the element is located, and its offset from the first element of that block.

The method will throw an std::out_of_range exception if the specified position is outside the current container range, except when the specified position is the position immediately after the last valid position, it will return a valid position object representing the end position.

Parameters
poslogical position of the element.
Returns
position object that stores an iterator referencing the element block where the element resides, and its offset within that block.

◆ position() [2/4]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
position_type mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::position ( const iterator pos_hint,
size_type  pos 
)

Given the logical position of an element, get the iterator of the block where the element is located, and its offset from the first element of that block.

The method will throw an std::out_of_range exception if the specified position is outside the current container range, except when the specified position is the position immediately after the last valid position, it will return a valid position object representing the end position.

Parameters
pos_hintiterator used as a block position hint, to specify which block to start when searching for the element position.
poslogical position of the element.
Returns
position object that stores an iterator referencing the element block where the element resides, and its offset within that block.

◆ position() [3/4]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
const_position_type mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::position ( size_type  pos) const

Given the logical position of an element, get an iterator referencing the element block where the element is located, and its offset from the first element of that block.

The method will throw an std::out_of_range exception if the specified position is outside the current container range.

Parameters
posposition of the element.
Returns
position object that stores an iterator referencing the element block where the element resides, and its offset within that block.

◆ position() [4/4]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
const_position_type mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::position ( const const_iterator pos_hint,
size_type  pos 
) const

Given the logical position of an element, get an iterator referencing the element block where the element is located, and its offset from the first element of that block.

The method will throw an std::out_of_range exception if the specified position is outside the current container range.

Parameters
pos_hintiterator used as a block position hint, to specify which block to start when searching for the element position.
poslogical position of the element.
Returns
position object that stores an iterator referencing the element block where the element resides, and its offset within the block.

◆ push_back()

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
template<typename _T >
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::push_back ( const _T &  value)

Append a new value to the end of the container.

Parameters
valuenew value to be appended to the end of the container.
Returns
iterator position pointing to the block where the value is appended, which in this case is always the last block of the container.

◆ push_back_empty()

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::push_back_empty ( )

Append a new empty element to the end of the container.

Returns
iterator position pointing to the block where the new empty element is appended, which in this case is always the last block of the container.

◆ release() [1/4]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
template<typename _T >
_T mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::release ( size_type  pos)

Return the value of an element at specified position and set that position empty. If the element resides in a managed element block, this call will release that element from that block. If the element is on a non-managed element block, this call is equivalent to set_empty(pos, pos).

The method will throw an std::out_of_range exception if the specified position is outside the current container range.

Parameters
posposition of the element to release.
Returns
element value.

◆ release() [2/4]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
template<typename _T >
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::release ( size_type  pos,
_T &  value 
)

Retrieve the value of an element at specified position and set that position empty. If the element resides in a managed element block, this call will release that element from that block. If the element is on a non-managed element block, this call is equivalent to set_empty(pos, pos).

The method will throw an std::out_of_range exception if the specified position is outside the current container range.

Parameters
posposition of the element to release.
valueelement value.
Returns
iterator referencing the block where the position of the released element is.

◆ release() [3/4]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
template<typename _T >
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::release ( const iterator pos_hint,
size_type  pos,
_T &  value 
)

Retrieve the value of an element at specified position and set that position empty. If the element resides in a managed element block, this call will release that element from that block. If the element is on a non-managed element block, this call is equivalent to set_empty(pos, pos).

The method will throw an std::out_of_range exception if the specified position is outside the current container range.

Parameters
posposition of the element to release.
valueelement value.
Returns
iterator referencing the block where the position of the released element is.

◆ release() [4/4]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
void mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::release ( )

Release all its elements, and empties its content. Calling this method relinquishes the ownership of all elements stored in managed element blocks if any.

This call is equivalent of clear() if the container consists of no managed element blocks.

◆ release_range() [1/2]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::release_range ( size_type  start_pos,
size_type  end_pos 
)

Make all elements within specified range empty, and relinquish the ownership of the elements in that range. All elements in the managed element blocks within the range will be released and the container will no longer manage their life cycles after the call.

The method will throw an std::out_of_range exception if either the starting or the ending position is outside the current container size.

Parameters
start_posstarting position
end_posending position, inclusive.
Returns
iterator position pointing to the block where the elements are released.

◆ release_range() [2/2]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::release_range ( const iterator pos_hint,
size_type  start_pos,
size_type  end_pos 
)

Make all elements within specified range empty, and relinquish the ownership of the elements in that range. All elements in the managed element blocks within the range will be released and the container will no longer manage their life cycles after the call.

This variant takes an iterator as an additional parameter, which is used as a block position hint to speed up the lookup of the first block to empty. The other variant that doesn't take an iterator always starts the block lookup from the first block, which does not scale well as the block size grows.

The method will throw an std::out_of_range exception if either the starting or the ending position is outside the current container size.

Parameters
pos_hintiterator used as a block position hint, to specify which block to start when searching for the right blocks in which elements are to be released.
start_posstarting position
end_posending position, inclusive.
Returns
iterator position pointing to the block where the elements are released.

◆ resize()

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
void mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::resize ( size_type  new_size)

Extend or shrink the container. When extending the container, it appends a series of empty elements to the end. When shrinking, the elements at the end of the container get stripped off.

Parameters
new_sizesize of the container after the resize.

◆ set() [1/4]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
template<typename _T >
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::set ( size_type  pos,
const _T &  value 
)

Set a value of an arbitrary type to a specified position. The type of the value is inferred from the value passed to this method. The new value will overwrite an existing value at the specified position position if any.

The method will throw an std::out_of_range exception if the specified position is outside the current container range.

Calling this method will not change the size of the container.

Parameters
posposition to insert the value to.
valuevalue to insert.
Returns
iterator position pointing to the block where the value is inserted.

◆ set() [2/4]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
template<typename _T >
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::set ( const iterator pos_hint,
size_type  pos,
const _T &  value 
)

Set a value of an arbitrary type to a specified position. The type of the value is inferred from the value passed to this method. The new value will overwrite an existing value at the specified position position if any.

This variant takes an iterator as an additional parameter, which is used as a block position hint to speed up the lookup of the right block to insert the value into. The other variant that doesn't take an iterator always starts the block lookup from the first block, which does not scale well as the block size grows.

This position hint iterator must precede the insertion position to yield any performance benefit.

The caller is responsible for ensuring that the passed iterator is valid. The behavior of this method when passing an invalid iterator is undefined.

The method will throw an std::out_of_range exception if the specified position is outside the current container range.

Calling this method will not change the size of the container.

Parameters
pos_hintiterator used as a block position hint, to specify which block to start when searching for the right block to insert the value into.
posposition to insert the value to.
valuevalue to insert.
Returns
iterator position pointing to the block where the value is inserted.

◆ set() [3/4]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
template<typename _T >
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::set ( size_type  pos,
const _T &  it_begin,
const _T &  it_end 
)

Set multiple values of identical type to a range of elements starting at specified position. Any existing values will be overwritten by the new values.

The method will throw an std::out_of_range exception if the range of new values would fall outside the current container range.

Calling this method will not change the size of the container.

Parameters
posposition of the first value of the series of new values being inserted.
it_beginiterator that points to the begin position of the values being set.
it_enditerator that points to the end position of the values being set.
Returns
iterator position pointing to the block where the value is inserted. When no value insertion occurs because the value set is empty, the end iterator position is returned.

◆ set() [4/4]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
template<typename _T >
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::set ( const iterator pos_hint,
size_type  pos,
const _T &  it_begin,
const _T &  it_end 
)

Set multiple values of identical type to a range of elements starting at specified position. Any existing values will be overwritten by the new values.

This variant takes an iterator as an additional parameter, which is used as a block position hint to speed up the lookup of the first insertion block. The other variant that doesn't take an iterator always starts the block lookup from the first block, which does not scale well as the block size grows.

This position hint iterator must precede the insertion position to yield any performance benefit.

The caller is responsible for ensuring that the passed iterator is valid. The behavior of this method when passing an invalid iterator is undefined.

The method will throw an std::out_of_range exception if the range of new values would fall outside the current container range.

Calling this method will not change the size of the container.

Parameters
pos_hintiterator used as a block position hint, to specify which block to start when searching for the right block to insert the value into.
posposition of the first value of the series of new values being inserted.
it_beginiterator that points to the begin position of the values being set.
it_enditerator that points to the end position of the values being set.
Returns
iterator position pointing to the block where the value is inserted. When no value insertion occurs because the value set is empty, the end iterator position is returned.

◆ set_empty() [1/2]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::set_empty ( size_type  start_pos,
size_type  end_pos 
)

Set specified range of elements to be empty. Any existing values will be overwritten.

The method will throw an std::out_of_range exception if either the starting or the ending position is outside the current container size.

Parameters
start_posstarting position
end_posending position, inclusive.
Returns
iterator position pointing to the block where the elements are emptied.

◆ set_empty() [2/2]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::set_empty ( const iterator pos_hint,
size_type  start_pos,
size_type  end_pos 
)

Set specified range of elements to be empty. Any existing values will be overwritten.

This variant takes an iterator as an additional parameter, which is used as a block position hint to speed up the lookup of the first block to empty. The other variant that doesn't take an iterator always starts the block lookup from the first block, which does not scale well as the block size grows.

This position hint iterator must precede the start position to yield any performance benefit.

The caller is responsible for ensuring that the passed iterator is valid. The behavior of this method when passing an invalid iterator is undefined.

The method will throw an std::out_of_range exception if either the starting or the ending position is outside the current container size.

Parameters
pos_hintiterator used as a block position hint, to specify which block to start when searching for the right blocks to empty.
start_posstarting position
end_posending position, inclusive.
Returns
iterator position pointing to the block where the elements are emptied.

◆ shrink_to_fit()

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
void mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::shrink_to_fit ( )

Trim excess capacity from all non-empty blocks.

◆ size()

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
size_type mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::size ( ) const

Return the current container size.

Returns
current container size.

◆ swap() [1/2]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
void mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::swap ( multi_type_vector< _ElemBlockFunc, _EventFunc > &  other)

Swap the content with another container.

Parameters
otheranother container to swap content with.

◆ swap() [2/2]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
void mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::swap ( size_type  start_pos,
size_type  end_pos,
multi_type_vector< _ElemBlockFunc, _EventFunc > &  other,
size_type  other_pos 
)

Swap a part of the content with another container.

Parameters
start_posstarting position
end_posending position, inclusive.
otheranother container to swap the content with.
other_posinsertion position in the other container.

◆ transfer() [1/2]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::transfer ( size_type  start_pos,
size_type  end_pos,
multi_type_vector< _ElemBlockFunc, _EventFunc > &  dest,
size_type  dest_pos 
)

Move elements from one container to another. After the move, the segment where the elements were in the source container becomes empty. When transferring managed elements, this call transfers ownership of the moved elements to the destination container. The moved elements will overwrite any existing elements in the destination range of the receiving container. Transfer of elements within the same container is not allowed.

The method will throw an std::out_of_range exception if either the starting or the ending position is greater than or equal to the source container size, or the destination container is not large enough to accommodate the transferred elements.

Parameters
start_posstarting position
end_posending position, inclusive.
destdestination container to which the elements are to be moved.
dest_posposition in the destination container to which the elements are to be moved.
Returns
iterator referencing the block where the moved elements were prior to the transfer.

◆ transfer() [2/2]

template<typename _ElemBlockFunc, typename _EventFunc = detail::mtv::event_func>
iterator mdds::multi_type_vector< _ElemBlockFunc, _EventFunc >::transfer ( const iterator pos_hint,
size_type  start_pos,
size_type  end_pos,
multi_type_vector< _ElemBlockFunc, _EventFunc > &  dest,
size_type  dest_pos 
)

Move elements from one container to another. After the move, the segment where the elements were in the source container becomes empty. When transferring managed elements, this call transfers ownership of the moved elements to the new container. The moved elements will overwrite any existing elements in the destination range of the receiving container. Transfer of elements within the same container is not allowed.

The method will throw an std::out_of_range exception if either the starting or the ending position is greater than or equal to the source container size, or the destination container is not large enough to accommodate the transferred elements.

Parameters
pos_hintiterator used as a block position hint, to specify which block to start when searching for the blocks where the elements to be transferred reside.
start_posstarting position
end_posending position, inclusive.
destdestination container to which the elements are to be moved.
dest_posposition in the destination container to which the elements are to be moved.
Returns
iterator referencing the block where the moved elements were prior to the transfer.