|
|
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 () noexcept(nothrow_default_constructible_v) |
| |
| | 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 (multi_type_vector &&other) noexcept(nothrow_move_constructible_v) |
| |
| | ~multi_type_vector () |
| |
| multi_type_vector | clone () const |
| |
| 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 (T &&value) |
| |
| iterator | push_back_empty () |
| |
| template<typename T , typename... Args> |
| iterator | emplace_back (Args &&... args) |
| |
| 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 noexcept(std::is_nothrow_copy_constructible_v< size_type >) |
| |
| size_type | block_size () const noexcept |
| |
| bool | empty () const noexcept |
| |
| void | resize (size_type new_size) |
| |
| void | swap (multi_type_vector &other) noexcept(nothrow_swappable_v) |
| |
| 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_vector & | operator= (const multi_type_vector &other) |
| |
|
multi_type_vector & | operator= (multi_type_vector &&other) noexcept(nothrow_move_assignable_v) |
| |
template<typename Traits = mdds::mtv::default_traits>
class mdds::mtv::aos::multi_type_vector< Traits >
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.
- See also
- mdds::mtv::aos::multi_type_vector::value_type
template<typename Traits = mdds::mtv::default_traits>
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.
template<typename Traits = mdds::mtv::default_traits>
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. |
template<typename Traits = mdds::mtv::default_traits>
template<typename T >
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 Traits = mdds::mtv::default_traits>
template<typename T >
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 Traits = mdds::mtv::default_traits>
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.
template<typename Traits = mdds::mtv::default_traits>
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.
template<typename Traits = mdds::mtv::default_traits>
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.
template<typename Traits = mdds::mtv::default_traits>
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.
template<typename Traits = mdds::mtv::default_traits>
template<typename T >
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.
template<typename Traits = mdds::mtv::default_traits>
template<typename T >
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 Traits = mdds::mtv::default_traits>
template<typename T >
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 Traits = mdds::mtv::default_traits>
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.
template<typename Traits = mdds::mtv::default_traits>
template<typename T >
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 Traits = mdds::mtv::default_traits>
template<typename T >
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 Traits = mdds::mtv::default_traits>
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.
template<typename Traits = mdds::mtv::default_traits>
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 Traits = mdds::mtv::default_traits>
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.