API Reference

Core

mdds::multi_type_vector

template<typename Traits = mtv::default_traits>
using mdds::multi_type_vector = mtv::soa::multi_type_vector<Traits>

Type alias for the concrete implementation to maintain backward API compatibility.

mdds::mtv::soa::multi_type_vector

template<typename Traits = mdds::mtv::default_traits>
class multi_type_vector

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:

  • 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.

This variant implements a structure-of-arrays (SoA) storage.

Public Types

using size_type = std::size_t
using element_block_type = mdds::mtv::base_element_block
using element_category_type = mdds::mtv::element_t
using block_funcs = typename Traits::block_funcs
using event_func = typename Traits::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::mtv::empty_event_func for the precise function signatures of the event handler functions.

using iterator = detail::iterator_base<iterator_trait>
using const_iterator = detail::const_iterator_base<const_iterator_trait, iterator>
using reverse_iterator = detail::iterator_base<reverse_iterator_trait>
using const_reverse_iterator = detail::const_iterator_base<const_reverse_iterator_trait, reverse_iterator>
using position_type = std::pair<iterator, size_type>
using const_position_type = std::pair<const_iterator, size_type>
using value_type = mdds::detail::mtv::iterator_value_node<multi_type_vector, size_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.

Public Functions

event_func &event_handler()
const event_func &event_handler() const
multi_type_vector()

Default constructor. It initializes the container with empty size.

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:

hdl – lvalue reference to an event handler object.

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:

hdl – rvalue reference to an event handler object.

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_size – initial container size.

template<typename T>
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_size – initial container size.

  • value – initial element value.

template<typename T>
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_size – initial container size.

  • it_begin – iterator that points to the begin position of the values the container is being initialized to.

  • it_end – iterator that points to the end position of the values the container is being initialized to. The end position is not inclusive.

multi_type_vector(const multi_type_vector &other)

Copy constructor.

Parameters:

other – the other instance to copy values from.

multi_type_vector(multi_type_vector &&other)

Move constructor.

Parameters:

other – the other instance to move values from.

~multi_type_vector()

Destructor. It deletes all allocated element blocks.

position_type 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:

pos – logical 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_type 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_hint – iterator used as a block position hint, to specify which block to start when searching for the element position.

  • pos – logical 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.

const_position_type 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:

pos – 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.

const_position_type 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_hint – iterator used as a block position hint, to specify which block to start when searching for the element position.

  • pos – logical 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.

iterator transfer(size_type start_pos, size_type end_pos, multi_type_vector &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_pos – starting position

  • end_pos – ending position, inclusive.

  • dest – destination container to which the elements are to be moved.

  • dest_pos – position 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.

iterator transfer(const iterator &pos_hint, size_type start_pos, size_type end_pos, multi_type_vector &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_hint – iterator 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_pos – starting position

  • end_pos – ending position, inclusive.

  • dest – destination container to which the elements are to be moved.

  • dest_pos – position 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.

template<typename T>
iterator 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:
  • pos – position to insert the value to.

  • value – value to insert.

Returns:

iterator position pointing to the block where the value is inserted.

template<typename T>
iterator 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_hint – iterator used as a block position hint, to specify which block to start when searching for the right block to insert the value into.

  • pos – position to insert the value to.

  • value – value to insert.

Returns:

iterator position pointing to the block where the value is inserted.

template<typename T>
iterator 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:
  • pos – position of the first value of the series of new values being inserted.

  • it_begin – iterator that points to the begin position of the values being set.

  • it_end – iterator 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.

template<typename T>
iterator 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_hint – iterator used as a block position hint, to specify which block to start when searching for the right block to insert the value into.

  • pos – position of the first value of the series of new values being inserted.

  • it_begin – iterator that points to the begin position of the values being set.

  • it_end – iterator 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.

template<typename T>
iterator push_back(const T &value)

Append a new value to the end of the container.

Parameters:

value – new 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.

iterator 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.

template<typename T>
iterator 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:
  • pos – position at which the new values are to be inserted.

  • it_begin – iterator that points to the begin position of the values being inserted.

  • it_end – iterator 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.

template<typename T>
iterator 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_hint – iterator used as a block position hint, to specify which block to start when searching for the right block to insert the value into.

  • pos – position at which the new values are to be inserted.

  • it_begin – iterator that points to the begin position of the values being inserted.

  • it_end – iterator 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.

mtv::element_t get_type(size_type pos) const

Get the type of an element at specified position.

Parameters:

pos – position of the element.

Returns:

element type.

bool 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:

pos – position of the element to check.

Returns:

true if the element is empty, false otherwise.

iterator 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_pos – starting position

  • end_pos – ending position, inclusive.

Returns:

iterator position pointing to the block where the elements are emptied.

iterator 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_hint – iterator used as a block position hint, to specify which block to start when searching for the right blocks to empty.

  • start_pos – starting position

  • end_pos – ending position, inclusive.

Returns:

iterator position pointing to the block where the elements are emptied.

void 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_pos – starting position

  • end_pos – ending position, inclusive.

iterator 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:
  • pos – position at which to insert a range of empty elements.

  • length – number 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.

iterator 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_hint – iterator 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.

  • pos – position at which to insert a range of empty elements.

  • length – number 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.

void clear()

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

size_type size() const

Return the current container size.

Returns:

current container size.

size_type 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 memory region (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.

bool empty() const

Return whether or not the container is empty.

Returns:

true if the container is empty, false otherwise.

template<typename T>
void 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:
  • pos – position of the element value to retrieve.

  • value – (out) variable to store the retrieved value.

template<typename T>
T 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:

pos – position of the element value to retrieve.

Returns:

element value.

template<typename T>
T 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:

pos – position of the element to release.

Returns:

element value.

template<typename T>
iterator 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:
  • pos – position of the element to release.

  • value – element value.

Returns:

iterator referencing the block where the position of the released element is.

template<typename T>
iterator 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:
  • pos_hint – iterator used as a block position hint, to specify which block to start when searching for the block where the element resides.

  • pos – position of the element to release.

  • value – element value.

Returns:

iterator referencing the block where the position of the released element is.

void 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.

iterator 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_pos – starting position

  • end_pos – ending position, inclusive.

Returns:

iterator position pointing to the block where the elements are released.

iterator 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_hint – iterator 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_pos – starting position

  • end_pos – ending position, inclusive.

Returns:

iterator position pointing to the block where the elements are released.

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
void 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_size – size of the container after the resize.

void swap(multi_type_vector &other)

Swap the content with another container.

Parameters:

other – another container to swap content with.

void swap(size_type start_pos, size_type end_pos, multi_type_vector &other, size_type other_pos)

Swap a part of the content with another instance.

Parameters:
  • start_pos – starting position

  • end_pos – ending position, inclusive.

  • other – another instance to swap the content with.

  • other_pos – insertion position in the other instance.

void shrink_to_fit()

Trim excess capacity from all non-empty blocks.

bool operator==(const multi_type_vector &other) const
bool operator!=(const multi_type_vector &other) const
multi_type_vector &operator=(const multi_type_vector &other)
multi_type_vector &operator=(multi_type_vector &&other)

Public Static Functions

static position_type next_position(const position_type &pos)

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

Parameters:

pos – position object.

Returns:

position object that points to the next logical position.

static position_type advance_position(const position_type &pos, int steps)

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

Parameters:
  • pos – position object.

  • steps – steps to advance the position object.

Returns:

position object that points to the new logical position.

static const_position_type next_position(const const_position_type &pos)

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

Parameters:

pos – position object.

Returns:

position object that points to the next logical position.

static const_position_type advance_position(const const_position_type &pos, int steps)

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

Parameters:
  • pos – position object.

  • steps – steps to advance the position object.

Returns:

position object that points to the new logical position.

static size_type logical_position(const const_position_type &pos)

Extract the logical position from a position object.

Parameters:

pos – position object.

Returns:

logical position of the element that the position object references.

template<typename _Blk>
static _Blk::value_type get(const const_position_type &pos)

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:

pos – position object.

Returns:

element value.

template<typename T>
static mtv::element_t get_element_type(const T &elem)

Return the numerical identifier that represents passed element.

Parameters:

elem – element value.

Returns:

numerical identifier representing the element.

mdds::mtv::aos::multi_type_vector

template<typename Traits = mdds::mtv::default_traits>
class multi_type_vector

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:

  • 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.

This variant implements an array-of-structures (AoS) storage.

Public Types

typedef size_t size_type
typedef mdds::mtv::base_element_block element_block_type
typedef mdds::mtv::element_t element_category_type
using block_funcs = typename Traits::block_funcs
using event_func = typename Traits::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::mtv::empty_event_func for the precise function signatures of the event handler functions.

typedef detail::iterator_base<iterator_trait, itr_forward_update> iterator
typedef detail::iterator_base<reverse_iterator_trait, itr_no_update> reverse_iterator
typedef detail::const_iterator_base<const_iterator_trait, itr_forward_update, iterator> const_iterator
typedef detail::const_iterator_base<const_reverse_iterator_trait, itr_no_update, reverse_iterator> const_reverse_iterator
typedef itr_node 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.

typedef std::pair<iterator, size_type> position_type
typedef std::pair<const_iterator, size_type> const_position_type

Public 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_func &event_handler()
const event_func &event_handler() const
multi_type_vector()

Default constructor. It initializes the container with empty size.

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:

hdl – lvalue reference to an event handler object.

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:

hdl – rvalue reference to an event handler object.

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_size – initial container size.

template<typename T>
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_size – initial container size.

  • value – initial element value.

template<typename T>
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_size – initial container size.

  • it_begin – iterator that points to the begin position of the values the container is being initialized to.

  • it_end – iterator that points to the end position of the values the container is being initialized to. The end position is not inclusive.

multi_type_vector(const multi_type_vector &other)

Copy constructor.

Parameters:

other – the other instance to copy values from.

multi_type_vector(multi_type_vector &&other)

Move constructor.

Parameters:

other – the other instance to move values from.

~multi_type_vector()

Destructor. It deletes all allocated data blocks.

template<typename T>
iterator 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:
  • pos – position to insert the value to.

  • value – value to insert.

Returns:

iterator position pointing to the block where the value is inserted.

template<typename T>
iterator 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_hint – iterator used as a block position hint, to specify which block to start when searching for the right block to insert the value into.

  • pos – position to insert the value to.

  • value – value to insert.

Returns:

iterator position pointing to the block where the value is inserted.

template<typename T>
iterator 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:
  • pos – position of the first value of the series of new values being inserted.

  • it_begin – iterator that points to the begin position of the values being set.

  • it_end – iterator 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.

template<typename T>
iterator 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_hint – iterator used as a block position hint, to specify which block to start when searching for the right block to insert the value into.

  • pos – position of the first value of the series of new values being inserted.

  • it_begin – iterator that points to the begin position of the values being set.

  • it_end – iterator 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.

template<typename T>
iterator push_back(const T &value)

Append a new value to the end of the container.

Parameters:

value – new 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.

iterator 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.

template<typename T>
iterator 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:
  • pos – position at which the new values are to be inserted.

  • it_begin – iterator that points to the begin position of the values being inserted.

  • it_end – iterator 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.

template<typename T>
iterator 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_hint – iterator used as a block position hint, to specify which block to start when searching for the right block to insert the value into.

  • pos – position at which the new values are to be inserted.

  • it_begin – iterator that points to the begin position of the values being inserted.

  • it_end – iterator 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.

template<typename T>
void 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:
  • pos – position of the element value to retrieve.

  • value – (out) variable to store the retrieved value.

template<typename T>
T 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:

pos – position of the element value to retrieve.

Returns:

element value.

template<typename T>
T 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:

pos – position of the element to release.

Returns:

element value.

template<typename T>
iterator 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:
  • pos – position of the element to release.

  • value – element value.

Returns:

iterator referencing the block where the position of the released element is.

template<typename T>
iterator 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:
  • pos_hint – iterator used as a block position hint, to specify which block to start when searching for the block where the element resides.

  • pos – position of the element to release.

  • value – element value.

Returns:

iterator referencing the block where the position of the released element is.

void 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.

iterator 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_pos – starting position

  • end_pos – ending position, inclusive.

Returns:

iterator position pointing to the block where the elements are released.

iterator 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_hint – iterator 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_pos – starting position

  • end_pos – ending position, inclusive.

Returns:

iterator position pointing to the block where the elements are released.

position_type 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:

pos – logical 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_type 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_hint – iterator used as a block position hint, to specify which block to start when searching for the element position.

  • pos – logical 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.

const_position_type 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:

pos – 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.

const_position_type 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_hint – iterator used as a block position hint, to specify which block to start when searching for the element position.

  • pos – logical 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.

iterator transfer(size_type start_pos, size_type end_pos, multi_type_vector &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_pos – starting position

  • end_pos – ending position, inclusive.

  • dest – destination container to which the elements are to be moved.

  • dest_pos – position 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.

iterator transfer(const iterator &pos_hint, size_type start_pos, size_type end_pos, multi_type_vector &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_hint – iterator 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_pos – starting position

  • end_pos – ending position, inclusive.

  • dest – destination container to which the elements are to be moved.

  • dest_pos – position 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.

mtv::element_t get_type(size_type pos) const

Get the type of an element at specified position.

Parameters:

pos – position of the element.

Returns:

element type.

bool 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:

pos – position of the element to check.

Returns:

true if the element is empty, false otherwise.

iterator 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_pos – starting position

  • end_pos – ending position, inclusive.

Returns:

iterator position pointing to the block where the elements are emptied.

iterator 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_hint – iterator used as a block position hint, to specify which block to start when searching for the right blocks to empty.

  • start_pos – starting position

  • end_pos – ending position, inclusive.

Returns:

iterator position pointing to the block where the elements are emptied.

void 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_pos – starting position

  • end_pos – ending position, inclusive.

iterator 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:
  • pos – position at which to insert a range of empty elements.

  • length – number 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.

iterator 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_hint – iterator 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.

  • pos – position at which to insert a range of empty elements.

  • length – number 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.

void clear()

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

size_type size() const

Return the current container size.

Returns:

current container size.

size_type 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.

bool empty() const

Return whether or not the container is empty.

Returns:

true if the container is empty, false otherwise.

void 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_size – size of the container after the resize.

void swap(multi_type_vector &other)

Swap the content with another container.

Parameters:

other – another container to swap content with.

void swap(size_type start_pos, size_type end_pos, multi_type_vector &other, size_type other_pos)

Swap a part of the content with another instance.

Parameters:
  • start_pos – starting position

  • end_pos – ending position, inclusive.

  • other – another instance to swap the content with.

  • other_pos – insertion position in the other instance.

void shrink_to_fit()

Trim excess capacity from all non-empty blocks.

bool operator==(const multi_type_vector &other) const
bool operator!=(const multi_type_vector &other) const
multi_type_vector &operator=(const multi_type_vector &other)
multi_type_vector &operator=(multi_type_vector &&other)

Public Static Functions

static position_type next_position(const position_type &pos)

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

Parameters:

pos – position object.

Returns:

position object that points to the next logical position.

static position_type advance_position(const position_type &pos, int steps)

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

Parameters:
  • pos – position object.

  • steps – steps to advance the position object.

Returns:

position object that points to the new logical position.

static const_position_type next_position(const const_position_type &pos)

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

Parameters:

pos – position object.

Returns:

position object that points to the next logical position.

static const_position_type advance_position(const const_position_type &pos, int steps)

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

Parameters:
  • pos – position object.

  • steps – steps to advance the position object.

Returns:

position object that points to the new logical position.

static size_type logical_position(const const_position_type &pos)

Extract the logical position from a position object.

Parameters:

pos – position object.

Returns:

logical position of the element that the position object references.

template<typename Blk>
static Blk::value_type get(const const_position_type &pos)

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:

pos – position object.

Returns:

element value.

template<typename T>
static mtv::element_t get_element_type(const T &elem)

Return the numerical identifier that represents passed element.

Parameters:

elem – element value.

Returns:

numerical identifier representing the element.

mdds::mtv::empty_event_func

struct empty_event_func

Empty event function handler structure, used when no custom function handler is specified.

Public Functions

inline void element_block_acquired(const base_element_block *block)

Callback function for element block acquisition events. This gets called whenever the container acquires a new element block either as a result of a new element block creation or a transfer of an existing element block from another container.

Parameters:

block – pointer to the acquired element block instance.

inline void element_block_released(const base_element_block *block)

Callback function for element block release events. This gets called whenever the container releases an existing element block either because the block is about to be deleted or to be transferred to another container.

Parameters:

block – pointer to the element block instance being released.

mdds::mtv::default_traits

struct default_traits

Default trait to be used when no custom trait is specified.

Subclassed by mdds::mtv::standard_element_blocks_traits

Public Types

using event_func = empty_event_func

Class or struct type that contains callback functions for element block events as its member functions.

using block_funcs = element_block_funcs<>

Type that contains block functions used throughout the multi_type_vector implementation. The user must overwrite this type to specify one or more block types as template arguments to element_block_funcs. Alternatively, you may be interested in using standard_element_blocks_traits which already supports the pre-defined block types for the optional standard data types.

Public Static Attributes

static constexpr lu_factor_t loop_unrolling = lu_factor_t::lu16

Static value specifying the loop-unrolling factor to use for the block position adjustment function. This must be a const expression.

Element Stores

template<typename T, typename Allocator = std::allocator<T>>
class delayed_delete_vector

Vector that delays deleting from the front of the vector, which avoids O(n^2) memory move operations when code needs to delete items from one element block and add to another element block.

Public Types

typedef store_type::value_type value_type
typedef store_type::size_type size_type
typedef store_type::difference_type difference_type
typedef store_type::reference reference
typedef store_type::const_reference const_reference
typedef store_type::pointer pointer
typedef store_type::const_pointer const_pointer
typedef store_type::iterator iterator
typedef store_type::reverse_iterator reverse_iterator
typedef store_type::const_iterator const_iterator
typedef store_type::const_reverse_iterator const_reverse_iterator

Public Functions

inline delayed_delete_vector()
inline delayed_delete_vector(size_t n, const T &val)
inline delayed_delete_vector(size_t n)
template<typename InputIt>
inline delayed_delete_vector(InputIt first, InputIt last)
inline iterator begin() noexcept
inline iterator end() noexcept
inline const_iterator begin() const noexcept
inline const_iterator end() const noexcept
inline reverse_iterator rbegin() noexcept
inline const_reverse_iterator rbegin() const noexcept
inline reverse_iterator rend() noexcept
inline const_reverse_iterator rend() const noexcept
inline reference operator[](size_type pos)
inline const_reference operator[](size_type pos) const
inline reference at(size_type pos)
inline const_reference at(size_type pos) const
inline void push_back(const T &value)
inline iterator insert(iterator pos, const T &value)
inline iterator insert(const_iterator pos, T &&value)
template<typename InputIt>
inline void insert(iterator pos, InputIt first, InputIt last)
inline void resize(size_type count)
inline iterator erase(iterator pos)
inline iterator erase(iterator first, iterator last)
inline size_type capacity() const noexcept
inline void shrink_to_fit()
inline void reserve(size_type new_cap)
inline size_type size() const
template<typename InputIt>
inline void assign(InputIt first, InputIt last)
inline T *data()
inline const T *data() const

Element Blocks

class base_element_block

Non-template common base type necessary for blocks of all types to be stored in a single container.

Subclassed by mdds::mtv::element_block< default_element_block< TypeId, ValueT, delayed_delete_vector >, TypeId, ValueT, delayed_delete_vector >, mdds::mtv::element_block< managed_element_block< TypeId, ValueT, delayed_delete_vector >, TypeId, ValueT *, delayed_delete_vector >, mdds::mtv::element_block< noncopyable_managed_element_block< TypeId, ValueT, delayed_delete_vector >, TypeId, ValueT *, delayed_delete_vector >, mdds::mtv::element_block< Self, TypeId, ValueT, StoreT >

template<typename Self, element_t TypeId, typename ValueT, template<typename, typename> class StoreT>
class element_block : public mdds::mtv::base_element_block

Subclassed by mdds::mtv::copyable_element_block< default_element_block< TypeId, ValueT, delayed_delete_vector >, TypeId, ValueT, delayed_delete_vector >, mdds::mtv::copyable_element_block< managed_element_block< TypeId, ValueT, delayed_delete_vector >, TypeId, ValueT *, delayed_delete_vector >, mdds::mtv::noncopyable_element_block< noncopyable_managed_element_block< TypeId, ValueT, delayed_delete_vector >, TypeId, ValueT *, delayed_delete_vector >, mdds::mtv::copyable_element_block< Self, TypeId, ValueT, StoreT >, mdds::mtv::noncopyable_element_block< Self, TypeId, ValueT, StoreT >

Public Types

using store_type = StoreT<ValueT, std::allocator<ValueT>>
typedef store_type::iterator iterator
typedef store_type::reverse_iterator reverse_iterator
typedef store_type::const_iterator const_iterator
typedef store_type::const_reverse_iterator const_reverse_iterator
typedef ValueT value_type
using range_type = base_range_type<true>
using const_range_type = base_range_type<false>

Public Functions

inline bool operator==(const Self &r) const
inline bool operator!=(const Self &r) const

Public Static Functions

static inline const value_type &at(const base_element_block &block, typename store_type::size_type pos)
static inline value_type &at(base_element_block &block, typename store_type::size_type pos)
static inline value_type *data(base_element_block &block)
static inline store_type::size_type size(const base_element_block &block)
static inline iterator begin(base_element_block &block)
static inline iterator end(base_element_block &block)
static inline const_iterator begin(const base_element_block &block)
static inline const_iterator end(const base_element_block &block)
static inline const_iterator cbegin(const base_element_block &block)
static inline const_iterator cend(const base_element_block &block)
static inline reverse_iterator rbegin(base_element_block &block)
static inline reverse_iterator rend(base_element_block &block)
static inline const_reverse_iterator rbegin(const base_element_block &block)
static inline const_reverse_iterator rend(const base_element_block &block)
static inline const_reverse_iterator crbegin(const base_element_block &block)
static inline const_reverse_iterator crend(const base_element_block &block)
static inline const_range_type range(const base_element_block &block)
static inline range_type range(base_element_block &block)
static inline Self &get(base_element_block &block)
static inline const Self &get(const base_element_block &block)
static inline void set_value(base_element_block &blk, size_t pos, const ValueT &val)
static inline void get_value(const base_element_block &blk, size_t pos, ValueT &val)
static inline value_type get_value(const base_element_block &blk, size_t pos)
static inline void append_value(base_element_block &blk, const ValueT &val)
static inline void prepend_value(base_element_block &blk, const ValueT &val)
static inline Self *create_block(size_t init_size)
static inline void delete_block(const base_element_block *p)
static inline void resize_block(base_element_block &blk, size_t new_size)
static inline void print_block(const base_element_block&)
static inline void erase_value(base_element_block &blk, size_t pos)
static inline void erase_values(base_element_block &blk, size_t pos, size_t size)
static inline void append_block(base_element_block &dest, const base_element_block &src)
static inline void append_values_from_block(base_element_block &dest, const base_element_block &src, size_t begin_pos, size_t len)
static inline void assign_values_from_block(base_element_block &dest, const base_element_block &src, size_t begin_pos, size_t len)
static inline void prepend_values_from_block(base_element_block &dest, const base_element_block &src, size_t begin_pos, size_t len)
static inline void swap_values(base_element_block &blk1, base_element_block &blk2, size_t pos1, size_t pos2, size_t len)
static inline bool equal_block(const base_element_block &left, const base_element_block &right)
template<typename Iter>
static inline void set_values(base_element_block &block, size_t pos, const Iter &it_begin, const Iter &it_end)
template<typename Iter>
static inline void append_values(base_element_block &block, const Iter &it_begin, const Iter &it_end)
template<typename Iter>
static inline void prepend_values(base_element_block &block, const Iter &it_begin, const Iter &it_end)
template<typename Iter>
static inline void assign_values(base_element_block &dest, const Iter &it_begin, const Iter &it_end)
template<typename Iter>
static inline void insert_values(base_element_block &block, size_t pos, const Iter &it_begin, const Iter &it_end)
static inline size_t capacity(const base_element_block &block)
static inline void reserve(base_element_block &block, std::size_t size)
static inline void shrink_to_fit(base_element_block &block)

Public Static Attributes

static constexpr element_t block_type = TypeId
template<element_t TypeId, typename ValueT, template<typename, typename> class StoreT = delayed_delete_vector>
struct default_element_block : public mdds::mtv::copyable_element_block<default_element_block<TypeId, ValueT, delayed_delete_vector>, TypeId, ValueT, delayed_delete_vector>

Template for default, unmanaged element block for use in multi_type_vector.

Public Types

using self_type = default_element_block<TypeId, ValueT, StoreT>
using base_type = copyable_element_block<self_type, TypeId, ValueT, StoreT>

Public Functions

inline default_element_block()
inline default_element_block(size_t n)
inline default_element_block(size_t n, const ValueT &val)
template<typename Iter>
inline default_element_block(const Iter &it_begin, const Iter &it_end)

Public Static Functions

static inline self_type *create_block_with_value(size_t init_size, const ValueT &val)
template<typename Iter>
static inline self_type *create_block_with_values(const Iter &it_begin, const Iter &it_end)
static inline void overwrite_values(base_element_block&, size_t, size_t)
template<typename Self, element_t TypeId, typename ValueT, template<typename, typename> class StoreT>
class copyable_element_block : public mdds::mtv::element_block<Self, TypeId, ValueT, StoreT>

Subclassed by mdds::mtv::default_element_block< TypeId, ValueT, StoreT >, mdds::mtv::managed_element_block< TypeId, ValueT, StoreT >

Public Static Functions

static inline Self *clone_block(const base_element_block &blk)
static inline Self &get(base_element_block &block)
static inline const Self &get(const base_element_block &block)
template<typename Self, element_t TypeId, typename ValueT, template<typename, typename> class StoreT>
class noncopyable_element_block : public mdds::mtv::element_block<Self, TypeId, ValueT, StoreT>

Subclassed by mdds::mtv::noncopyable_managed_element_block< TypeId, ValueT, StoreT >

Public Functions

noncopyable_element_block(const noncopyable_element_block&) = delete
noncopyable_element_block &operator=(const noncopyable_element_block&) = delete

Public Static Functions

static inline Self *clone_block(const base_element_block&)
template<element_t TypeId, typename ValueT, template<typename, typename> class StoreT = delayed_delete_vector>
struct managed_element_block : public mdds::mtv::copyable_element_block<managed_element_block<TypeId, ValueT, delayed_delete_vector>, TypeId, ValueT*, delayed_delete_vector>

Template for element block that stores pointers to objects whose life cycles are managed by the block.

Public Types

using self_type = managed_element_block<TypeId, ValueT, StoreT>
using base_type = copyable_element_block<self_type, TypeId, ValueT*, StoreT>

Public Functions

inline managed_element_block()
inline managed_element_block(size_t n)
inline managed_element_block(const managed_element_block &r)
template<typename Iter>
inline managed_element_block(const Iter &it_begin, const Iter &it_end)
inline ~managed_element_block()

Public Static Functions

static inline self_type *create_block_with_value(size_t init_size, ValueT *val)
template<typename Iter>
static inline self_type *create_block_with_values(const Iter &it_begin, const Iter &it_end)
static inline void overwrite_values(base_element_block &block, size_t pos, size_t len)
static inline Self &get(base_element_block &block)
static inline const Self &get(const base_element_block &block)
template<element_t TypeId, typename ValueT, template<typename, typename> class StoreT = delayed_delete_vector>
struct noncopyable_managed_element_block : public mdds::mtv::noncopyable_element_block<noncopyable_managed_element_block<TypeId, ValueT, delayed_delete_vector>, TypeId, ValueT*, delayed_delete_vector>

Public Functions

inline noncopyable_managed_element_block()
inline noncopyable_managed_element_block(size_t n)
template<typename Iter>
inline noncopyable_managed_element_block(const Iter &it_begin, const Iter &it_end)
inline ~noncopyable_managed_element_block()

Public Static Functions

static inline self_type *create_block_with_value(size_t init_size, ValueT *val)
template<typename Iter>
static inline self_type *create_block_with_values(const Iter &it_begin, const Iter &it_end)
static inline void overwrite_values(base_element_block &block, size_t pos, size_t len)
template<typename ...Ts>
struct element_block_funcs

Public Static Functions

static inline base_element_block *create_new_block(element_t type, std::size_t init_size)
static inline base_element_block *clone_block(const base_element_block &block)
static inline void delete_block(const base_element_block *p)
static inline void resize_block(base_element_block &block, std::size_t new_size)
static inline void print_block(const base_element_block &block)
static inline void erase(base_element_block &block, std::size_t pos)
static inline void erase(base_element_block &block, std::size_t pos, std::size_t size)
static inline void append_block(base_element_block &dest, const base_element_block &src)
static inline void append_values_from_block(base_element_block &dest, const base_element_block &src, std::size_t begin_pos, std::size_t len)
static inline void assign_values_from_block(base_element_block &dest, const base_element_block &src, std::size_t begin_pos, std::size_t len)
static inline void prepend_values_from_block(base_element_block &dest, const base_element_block &src, std::size_t begin_pos, std::size_t len)
static inline void swap_values(base_element_block &blk1, base_element_block &blk2, std::size_t pos1, std::size_t pos2, std::size_t len)
static inline bool equal_block(const base_element_block &left, const base_element_block &right)
static inline void overwrite_values(base_element_block &block, std::size_t pos, std::size_t len)
static inline void shrink_to_fit(base_element_block &block)
static inline std::size_t size(const base_element_block &block)

Types

mdds::mtv::element_t

using mdds::mtv::element_t = int
constexpr element_t mdds::mtv::element_type_empty = -1
constexpr element_t mdds::mtv::element_type_reserved_start = 0
constexpr element_t mdds::mtv::element_type_reserved_end = 49
constexpr element_t mdds::mtv::element_type_user_start = 50

mdds::mtv::lu_factor_t

enum class mdds::mtv::lu_factor_t : int

Loop-unrolling factor with optional SIMD feature.

In each enumerator value, the first byte contains the loop-unrolling factor (either 0, 4, 8, 16 or 32), while the second byte stores SIMD flags.

Values:

enumerator none
enumerator lu4
enumerator lu8
enumerator lu16
enumerator lu32
enumerator sse2_x64
enumerator sse2_x64_lu4
enumerator sse2_x64_lu8
enumerator sse2_x64_lu16
enumerator avx2_x64
enumerator avx2_x64_lu4
enumerator avx2_x64_lu8

mdds::mtv::trace_method_t

enum class mdds::mtv::trace_method_t : int

Type of traced method.

An accessor in this context is a method whose call alone does not mutate the state of the container. All const methods are accessors. Note that some non-const methods that return non-const references to internal data are still considered accessors.

A mutator is a method that, when called, may change the state of the stored data immediately.

The accessor_with_pos_hint label signifies an accessor that takes a position hint as its first argument. Likewise, mutator_with_pos_hint signifies a mutator that takes a position hint as its first argument.

The constructor and destructor labels are hopefully self-explanatory.

Values:

enumerator unspecified
enumerator accessor
enumerator accessor_with_pos_hint
enumerator mutator
enumerator mutator_with_pos_hint
enumerator constructor
enumerator destructor

mdds::mtv::trace_method_properties_t

struct trace_method_properties_t

Struct containing the information about each traced method.

Public Members

trace_method_t type = trace_method_t::unspecified
const void *instance = nullptr

Memory address of the container instance the traced method belongs to. This is essentially the this pointer inside the traced method.

const char *function_name = nullptr

Name of the method.

std::string function_args

String containing the argument names as well as their values if available.

const char *filepath = nullptr

Path of the file where the method body is.

int line_number = -1

Line number of the first line of the traced method body.

Standard Element Blocks

The following types are automatically defined by default when including one of the following headers:

  • mdds/multi_type_vector.hpp

  • mdds/multi_type_vector/aos/main.hpp

  • mdds/multi_type_vector/soa/main.hpp

To disable automatic definitions of these standard element block types, you must define the MDDS_MTV_USE_STANDARD_ELEMENT_BLOCKS macro and set its value to 0. Refer to the Specifying different storage type section for more details on when you may want to disable these block types.

Constants

constexpr element_t mdds::mtv::element_type_boolean = element_type_reserved_start
constexpr element_t mdds::mtv::element_type_int8 = element_type_reserved_start + 1
constexpr element_t mdds::mtv::element_type_uint8 = element_type_reserved_start + 2
constexpr element_t mdds::mtv::element_type_int16 = element_type_reserved_start + 3
constexpr element_t mdds::mtv::element_type_uint16 = element_type_reserved_start + 4
constexpr element_t mdds::mtv::element_type_int32 = element_type_reserved_start + 5
constexpr element_t mdds::mtv::element_type_uint32 = element_type_reserved_start + 6
constexpr element_t mdds::mtv::element_type_int64 = element_type_reserved_start + 7
constexpr element_t mdds::mtv::element_type_uint64 = element_type_reserved_start + 8
constexpr element_t mdds::mtv::element_type_float = element_type_reserved_start + 9
constexpr element_t mdds::mtv::element_type_double = element_type_reserved_start + 10
constexpr element_t mdds::mtv::element_type_string = element_type_reserved_start + 11

Block Types and Traits

using mdds::mtv::boolean_element_block = default_element_block<element_type_boolean, bool>
using mdds::mtv::int8_element_block = default_element_block<element_type_int8, int8_t>
using mdds::mtv::uint8_element_block = default_element_block<element_type_uint8, uint8_t>
using mdds::mtv::int16_element_block = default_element_block<element_type_int16, int16_t>
using mdds::mtv::uint16_element_block = default_element_block<element_type_uint16, uint16_t>
using mdds::mtv::int32_element_block = default_element_block<element_type_int32, int32_t>
using mdds::mtv::uint32_element_block = default_element_block<element_type_uint32, uint32_t>
using mdds::mtv::int64_element_block = default_element_block<element_type_int64, int64_t>
using mdds::mtv::uint64_element_block = default_element_block<element_type_uint64, uint64_t>
using mdds::mtv::float_element_block = default_element_block<element_type_float, float>
using mdds::mtv::double_element_block = default_element_block<element_type_double, double>
using mdds::mtv::string_element_block = default_element_block<element_type_string, std::string>
struct standard_element_blocks_traits : public mdds::mtv::default_traits

Exceptions

class element_block_error : public mdds::general_error

Generic exception used for errors specific to element block operations.

Public Functions

inline element_block_error(const std::string &msg)

Macros

MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(type, type_id, empty_value, block_type)

Defines required callback functions for multi_type_vector.

Parameters:
  • type – element value type.

  • type_id – constant value used as an ID for the value type. It should be of type mdds::mtv::element_t.

  • empty_value – value that should be used as the default “false” value for the value type.

  • block_type – block type that stores the specified value type.

MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(type, type_id, empty_value, block_type)

A variant of MDDS_MTV_DEFINE_ELEMENT_CALLBACKS that should be used for a pointer type.

Collection

template<typename _MtvT>
class collection

Special-purpose collection of multiple multi_type_vector instances to allow them to be traversed “sideways” i.e. orthogonal to the direction of the vector instances. All involved multi_type_vector instances must be of the same type and length.

Public Types

typedef _MtvT mtv_type
typedef mtv_type::size_type size_type
typedef detail::side_iterator<mtv_type> const_iterator

collection range.

Public Functions

collection()
template<typename _T>
collection(const _T &begin, const _T &end)

Constructor that takes the start and end iterators of the multi_type_vector instances to reference in the collection.

Parameters:
  • begin – iterator that references the first multi_type_vector instance to place in the collection.

  • end – iterator that references the position past the last multi_type_vector instance to place in the collection.

const_iterator begin() const

Return an iterator that references the first element in the collection.

Returns:

iterator that references the first element in the collection.

const_iterator end() const

Return an iterator that references the position past the last element in the collection.

Returns:

iterator that references the position past the last element in the collection.

size_type size() const

Return the length of the vector instances stored in the collection. This will be equivalent of the length of each multi_type_vector instance, since all stored instances have the same length.

Returns:

length of the stored multi_type_vector instances.

void swap(collection &other)

Swap the entire collection with another collection instance.

Parameters:

other – another collection instance to swap contents with.

void set_collection_range(size_type start, size_type size)

Set the sub-range of the collection to iterate through.

For instance, if the collection consists of 100 multi_type_vector instances, and you want to iterate through only 50 of them starting from the second instance, you set the start index to 1 (as it’s 0-based), and the size to 50.

Parameters:
  • start – 0-based index of the first multi_type_vector instance to iterate through.

  • size – length of the collection range i.e. the number of vector instances to iterate through starting from the specified first vector instance.

void set_element_range(size_type start, size_type size)

Set the sub element range to iterate through. This limits the element range in each multi_type_vector instance to iterate through. The direction of the element range is orthogonal to the direction of the collection range.

For instance, if the collection consists of multiple multi_type_vector instances all of which have a length of 50, and you only wish to iterate from the 3rd element through the 10th element in each vector instance, then you set the start index to 2 and the size to 8.

Parameters:
  • start – 0-based index of the starting element position.

  • size – length of the element range to iterate through starting from the specified start element position.