Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
#include <flex_vector.hpp>
Public Types | |
using | memory_policy = MemoryPolicy |
using | value_type = T |
using | reference = const T & |
using | size_type = detail::rbts::size_t |
using | difference_type = std::ptrdiff_t |
using | const_reference = const T & |
using | iterator = detail::rbts::rbtree_iterator< T, MemoryPolicy, B, BL > |
using | const_iterator = iterator |
using | reverse_iterator = std::reverse_iterator< iterator > |
using | transient_type = vector_transient< T, MemoryPolicy, B, BL > |
Public Member Functions | |
vector ()=default | |
vector (std::initializer_list< T > values) | |
template<typename Iter , typename Sent , std::enable_if_t< detail::compatible_sentinel_v< Iter, Sent >, bool > = true> | |
vector (Iter first, Sent last) | |
vector (size_type n, T v={}) | |
iterator | begin () const |
iterator | end () const |
reverse_iterator | rbegin () const |
reverse_iterator | rend () const |
size_type | size () const |
bool | empty () const |
const T & | back () const |
const T & | front () const |
reference | operator[] (size_type index) const |
reference | at (size_type index) const |
bool | operator== (const vector &other) const |
bool | operator!= (const vector &other) const |
vector | push_back (value_type value) const & |
decltype(auto) | push_back (value_type value) && |
vector | set (size_type index, value_type value) const & |
decltype(auto) | set (size_type index, value_type value) && |
template<typename FnT > | |
vector | update (size_type index, FnT &&fn) const & |
template<typename FnT > | |
decltype(auto) | update (size_type index, FnT &&fn) && |
vector | take (size_type elems) const & |
decltype(auto) | take (size_type elems) && |
transient_type | transient () const & |
transient_type | transient () && |
const impl_t & | impl () const |
Static Public Attributes | |
static constexpr auto | bits = B |
static constexpr auto | bits_leaf = BL |
Private Types | |
using | impl_t = detail::rbts::rbtree< T, MemoryPolicy, B, BL > |
using | flex_t = flex_vector< T, MemoryPolicy, B, BL > |
using | move_t = std::integral_constant< bool, MemoryPolicy::use_transient_rvalues > |
Private Member Functions | |
vector (impl_t impl) | |
vector && | push_back_move (std::true_type, value_type value) |
vector | push_back_move (std::false_type, value_type value) |
vector && | set_move (std::true_type, size_type index, value_type value) |
vector | set_move (std::false_type, size_type index, value_type value) |
template<typename Fn > | |
vector && | update_move (std::true_type, size_type index, Fn &&fn) |
template<typename Fn > | |
vector | update_move (std::false_type, size_type index, Fn &&fn) |
vector && | take_move (std::true_type, size_type elems) |
vector | take_move (std::false_type, size_type elems) |
Private Attributes | |
friend | flex_t |
friend | transient_type |
impl_t | impl_ = impl_t::empty() |
Detailed Description
template<typename T, typename MemoryPolicy = default_memory_policy, detail::rbts::bits_t B = default_bits, detail::rbts::bits_t BL = detail::rbts::derive_bits_leaf<T, MemoryPolicy, B>>
class immer::vector< T, MemoryPolicy, B, BL >
Immutable sequential container supporting both random access and structural sharing.
- Template Parameters
-
T The type of the values to be stored in the container. MemoryPolicy Memory management policy. See memory_policy.
This cotainer provides a good trade-off between cache locality, random access, update performance and structural sharing. It does so by storing the data in contiguous chunks of :math:2^{BL}
elements. By default, when sizeof(T) == sizeof(void*)
then :math:B=BL=5
, such that data would be stored in contiguous chunks of :math:32
elements.
You may learn more about the meaning and implications of B
and BL
parameters in the :doc:implementation
section.
.. note:: In several methods we say that their complexity is effectively :math:O(...)
. Do not confuse this with the word amortized, which has a very different meaning. In this context, effective means that while the mathematically rigurous complexity might be higher, for all practical matters the provided complexity is more useful to think about the actual cost of the operation.
Example .. literalinclude:: ../example/vector/intro.cpp :language: c++ :start-after: intro/start :end-before: intro/end
Definition at line 21 of file flex_vector.hpp.
Member Typedef Documentation
◆ const_iterator
using immer::vector< T, MemoryPolicy, B, BL >::const_iterator = iterator |
Definition at line 94 of file vector.hpp.
◆ const_reference
using immer::vector< T, MemoryPolicy, B, BL >::const_reference = const T& |
Definition at line 91 of file vector.hpp.
◆ difference_type
using immer::vector< T, MemoryPolicy, B, BL >::difference_type = std::ptrdiff_t |
Definition at line 90 of file vector.hpp.
◆ flex_t
|
private |
Definition at line 77 of file vector.hpp.
◆ impl_t
|
private |
Definition at line 76 of file vector.hpp.
◆ iterator
using immer::vector< T, MemoryPolicy, B, BL >::iterator = detail::rbts::rbtree_iterator<T, MemoryPolicy, B, BL> |
Definition at line 93 of file vector.hpp.
◆ memory_policy
using immer::vector< T, MemoryPolicy, B, BL >::memory_policy = MemoryPolicy |
Definition at line 85 of file vector.hpp.
◆ move_t
|
private |
Definition at line 80 of file vector.hpp.
◆ reference
using immer::vector< T, MemoryPolicy, B, BL >::reference = const T& |
Definition at line 88 of file vector.hpp.
◆ reverse_iterator
using immer::vector< T, MemoryPolicy, B, BL >::reverse_iterator = std::reverse_iterator<iterator> |
Definition at line 95 of file vector.hpp.
◆ size_type
using immer::vector< T, MemoryPolicy, B, BL >::size_type = detail::rbts::size_t |
Definition at line 89 of file vector.hpp.
◆ transient_type
using immer::vector< T, MemoryPolicy, B, BL >::transient_type = vector_transient<T, MemoryPolicy, B, BL> |
Definition at line 97 of file vector.hpp.
◆ value_type
using immer::vector< T, MemoryPolicy, B, BL >::value_type = T |
Definition at line 87 of file vector.hpp.
Constructor & Destructor Documentation
◆ vector() [1/5]
|
default |
Default constructor. It creates a vector of size() == 0
. It does not allocate memory and its complexity is .
◆ vector() [2/5]
|
inline |
Constructs a vector containing the elements in values
.
Definition at line 108 of file vector.hpp.
References immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::from_initializer_list().
◆ vector() [3/5]
|
inline |
Constructs a vector containing the elements in the range defined by the input iterator first
and range sentinel last
.
Definition at line 119 of file vector.hpp.
References immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::from_range().
◆ vector() [4/5]
|
inline |
Constructs a vector containing the element val
repeated n
times.
Definition at line 127 of file vector.hpp.
◆ vector() [5/5]
|
inlineprivate |
Definition at line 319 of file vector.hpp.
Member Function Documentation
◆ at()
|
inline |
Returns a const
reference to the element at position index
. It throws an std::out_of_range
exception when . It does not allocate memory and its complexity is effectively .
Definition at line 195 of file vector.hpp.
References immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::get_check(), and immer::vector< T, MemoryPolicy, B, BL >::impl_.
◆ back()
|
inline |
Access the last element.
Definition at line 173 of file vector.hpp.
References immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::back(), and immer::vector< T, MemoryPolicy, B, BL >::impl_.
◆ begin()
|
inline |
Returns an iterator pointing at the first element of the collection. It does not allocate memory and its complexity is .
Definition at line 136 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::impl_.
Referenced by immer::vector< T, MemoryPolicy, B, BL >::rend().
◆ empty()
|
inline |
Returns true
if there are no elements in the container. It does not allocate memory and its complexity is .
Definition at line 168 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::impl_, and immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::size.
◆ end()
|
inline |
Returns an iterator pointing just after the last element of the collection. It does not allocate and its complexity is .
Definition at line 142 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::impl_.
Referenced by immer::vector< T, MemoryPolicy, B, BL >::rbegin().
◆ front()
|
inline |
Access the first element.
Definition at line 178 of file vector.hpp.
References immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::front(), and immer::vector< T, MemoryPolicy, B, BL >::impl_.
◆ impl()
|
inline |
Definition at line 308 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::impl_.
◆ operator!=()
|
inline |
Definition at line 203 of file vector.hpp.
◆ operator==()
|
inline |
Returns whether the vectors are equal.
Definition at line 201 of file vector.hpp.
References immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::equals(), and immer::vector< T, MemoryPolicy, B, BL >::impl_.
◆ operator[]()
|
inline |
Returns a const
reference to the element at position index
. It is undefined when . It does not allocate memory and its complexity is effectively .
Definition at line 186 of file vector.hpp.
References immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::get(), and immer::vector< T, MemoryPolicy, B, BL >::impl_.
◆ push_back() [1/2]
|
inline |
Returns a vector with value
inserted at the end. It may allocate memory and its complexity is effectively .
Example .. literalinclude:: ../example/vector/vector.cpp :language: c++ :dedent: 8 :start-after: push-back/start :end-before: push-back/end
Definition at line 221 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::impl_, and immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::push_back().
◆ push_back() [2/2]
|
inline |
Definition at line 224 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::push_back_move().
◆ push_back_move() [1/2]
|
inlineprivate |
Definition at line 329 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::impl_, and immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::push_back_mut().
Referenced by immer::vector< T, MemoryPolicy, B, BL >::push_back().
◆ push_back_move() [2/2]
|
inlineprivate |
Definition at line 331 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::impl_, and immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::push_back().
◆ rbegin()
|
inline |
Returns an iterator that traverses the collection backwards, pointing at the first element of the reversed collection. It does not allocate memory and its complexity is .
Definition at line 149 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::end().
◆ rend()
|
inline |
Returns an iterator that traverses the collection backwards, pointing after the last element of the reversed collection. It does not allocate memory and its complexity is .
Definition at line 156 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::begin().
◆ set() [1/2]
|
inline |
Returns a vector containing value value
at position idx
. Undefined for index >= size()
. It may allocate memory and its complexity is effectively .
Example .. literalinclude:: ../example/vector/vector.cpp :language: c++ :dedent: 8 :start-after: set/start :end-before: set/end
Definition at line 244 of file vector.hpp.
References immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::assoc(), and immer::vector< T, MemoryPolicy, B, BL >::impl_.
◆ set() [2/2]
|
inline |
Definition at line 247 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::set_move().
◆ set_move() [1/2]
|
inlineprivate |
Definition at line 334 of file vector.hpp.
References immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::assoc_mut(), and immer::vector< T, MemoryPolicy, B, BL >::impl_.
Referenced by immer::vector< T, MemoryPolicy, B, BL >::set().
◆ set_move() [2/2]
|
inlineprivate |
Definition at line 336 of file vector.hpp.
References immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::assoc(), and immer::vector< T, MemoryPolicy, B, BL >::impl_.
◆ size()
|
inline |
Returns the number of elements in the container. It does not allocate memory and its complexity is .
Definition at line 162 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::impl_, and immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::size.
◆ take() [1/2]
|
inline |
Returns a vector containing only the first min(elems, size())
elements. It may allocate memory and its complexity is effectively .
Example .. literalinclude:: ../example/vector/vector.cpp :language: c++ :dedent: 8 :start-after: take/start :end-before: take/end
Definition at line 292 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::impl_, and immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::take().
◆ take() [2/2]
|
inline |
Definition at line 295 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::take_move().
◆ take_move() [1/2]
|
inlineprivate |
Definition at line 346 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::impl_, and immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::take_mut().
Referenced by immer::vector< T, MemoryPolicy, B, BL >::take().
◆ take_move() [2/2]
|
inlineprivate |
Definition at line 348 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::impl_, and immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::take().
◆ transient() [1/2]
|
inline |
Returns an transient form of this container, an immer::vector_transient
.
Definition at line 302 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::impl_.
◆ transient() [2/2]
|
inline |
Definition at line 304 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::impl_.
◆ update() [1/2]
|
inline |
Returns a vector containing the result of the expression fn((*this)[idx])
at position idx
. Undefined for 0 >= size()
. It may allocate memory and its complexity is effectively .
Example .. literalinclude:: ../example/vector/vector.cpp :language: c++ :dedent: 8 :start-after: update/start :end-before: update/end
Definition at line 269 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::impl_, and immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::update().
◆ update() [2/2]
|
inline |
Definition at line 273 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::update_move().
◆ update_move() [1/2]
|
inlineprivate |
Definition at line 340 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::impl_, and immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::update_mut().
Referenced by immer::vector< T, MemoryPolicy, B, BL >::update().
◆ update_move() [2/2]
|
inlineprivate |
Definition at line 343 of file vector.hpp.
References immer::vector< T, MemoryPolicy, B, BL >::impl_, and immer::detail::rbts::rbtree< T, MemoryPolicy, B, BL >::update().
Member Data Documentation
◆ bits
|
static |
Definition at line 83 of file vector.hpp.
◆ bits_leaf
|
static |
Definition at line 84 of file vector.hpp.
◆ flex_t
|
private |
Definition at line 316 of file vector.hpp.
◆ impl_
|
private |
Definition at line 351 of file vector.hpp.
Referenced by immer::vector< T, MemoryPolicy, B, BL >::at(), immer::vector< T, MemoryPolicy, B, BL >::back(), immer::vector< T, MemoryPolicy, B, BL >::begin(), immer::vector< T, MemoryPolicy, B, BL >::empty(), immer::vector< T, MemoryPolicy, B, BL >::end(), immer::flex_vector< T, MemoryPolicy, B, BL >::flex_vector(), immer::vector< T, MemoryPolicy, B, BL >::front(), immer::vector< T, MemoryPolicy, B, BL >::impl(), immer::vector< T, MemoryPolicy, B, BL >::operator==(), immer::vector< T, MemoryPolicy, B, BL >::operator[](), immer::vector< T, MemoryPolicy, B, BL >::push_back(), immer::vector< T, MemoryPolicy, B, BL >::push_back_move(), immer::vector< T, MemoryPolicy, B, BL >::set(), immer::vector< T, MemoryPolicy, B, BL >::set_move(), immer::vector< T, MemoryPolicy, B, BL >::size(), immer::vector< T, MemoryPolicy, B, BL >::take(), immer::vector< T, MemoryPolicy, B, BL >::take_move(), immer::vector< T, MemoryPolicy, B, BL >::transient(), immer::vector< T, MemoryPolicy, B, BL >::update(), and immer::vector< T, MemoryPolicy, B, BL >::update_move().
◆ transient_type
|
private |
Definition at line 317 of file vector.hpp.
The documentation for this class was generated from the following files:
- src/immer/flex_vector.hpp
- src/immer/vector.hpp