Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
#include <array.hpp>
Public Types | |
using | value_type = T |
using | reference = const T & |
using | size_type = std::size_t |
using | difference_type = std::ptrdiff_t |
using | const_reference = const T & |
using | iterator = const T * |
using | const_iterator = iterator |
using | reverse_iterator = std::reverse_iterator< iterator > |
using | memory_policy = MemoryPolicy |
using | transient_type = array_transient< T, MemoryPolicy > |
Public Member Functions | |
array ()=default | |
array (std::initializer_list< T > values) | |
template<typename Iter , typename Sent , std::enable_if_t< detail::compatible_sentinel_v< Iter, Sent > &&detail::is_forward_iterator_v< Iter >, bool > = true> | |
array (Iter first, Sent last) | |
array (size_type n, T v={}) | |
iterator | begin () const |
iterator | end () const |
reverse_iterator | rbegin () const |
reverse_iterator | rend () const |
std::size_t | size () const |
bool | empty () const |
const T * | data () const |
const T & | back () const |
const T & | front () const |
reference | operator[] (size_type index) const |
reference | at (size_type index) const |
bool | operator== (const array &other) const |
bool | operator!= (const array &other) const |
array | push_back (value_type value) const & |
decltype(auto) | push_back (value_type value) && |
array | set (std::size_t index, value_type value) const & |
decltype(auto) | set (size_type index, value_type value) && |
template<typename FnT > | |
array | update (std::size_t index, FnT &&fn) const & |
template<typename FnT > | |
decltype(auto) | update (size_type index, FnT &&fn) && |
array | take (size_type elems) const & |
decltype(auto) | take (size_type elems) && |
transient_type | transient () const & |
transient_type | transient () && |
const impl_t & | impl () const |
Private Types | |
using | impl_t = std::conditional_t< MemoryPolicy::use_transient_rvalues, detail::arrays::with_capacity< T, MemoryPolicy >, detail::arrays::no_capacity< T, MemoryPolicy > > |
using | move_t = std::integral_constant< bool, MemoryPolicy::use_transient_rvalues > |
Private Member Functions | |
array (impl_t impl) | |
array && | push_back_move (std::true_type, value_type value) |
array | push_back_move (std::false_type, value_type value) |
array && | set_move (std::true_type, size_type index, value_type value) |
array | set_move (std::false_type, size_type index, value_type value) |
template<typename Fn > | |
array && | update_move (std::true_type, size_type index, Fn &&fn) |
template<typename Fn > | |
array | update_move (std::false_type, size_type index, Fn &&fn) |
array && | take_move (std::true_type, size_type elems) |
array | take_move (std::false_type, size_type elems) |
Private Attributes | |
friend | transient_type |
impl_t | impl_ = impl_t::empty() |
Detailed Description
template<typename T, typename MemoryPolicy = default_memory_policy>
class immer::array< T, MemoryPolicy >
Immutable container that stores a sequence of elements in contiguous memory.
- Template Parameters
-
T The type of the values to be stored in the container.
It supports the most efficient iteration and random access, equivalent to a std::vector
or std::array
, but all manipulations are :math:O(size)
.
.. tip:: Don't be fooled by the bad complexity of this data structure. It is a great choice for short sequence or when it is seldom or never changed. This depends on the sizeof(T)
and the expensiveness of its T
's copy constructor, in case of doubt, measure. For basic types, using an array
when :math:n < 100
is a good heuristic.
Member Typedef Documentation
◆ const_iterator
using immer::array< T, MemoryPolicy >::const_iterator = iterator |
◆ const_reference
using immer::array< T, MemoryPolicy >::const_reference = const T& |
◆ difference_type
using immer::array< T, MemoryPolicy >::difference_type = std::ptrdiff_t |
◆ impl_t
|
private |
◆ iterator
using immer::array< T, MemoryPolicy >::iterator = const T* |
◆ memory_policy
using immer::array< T, MemoryPolicy >::memory_policy = MemoryPolicy |
◆ move_t
|
private |
◆ reference
using immer::array< T, MemoryPolicy >::reference = const T& |
◆ reverse_iterator
using immer::array< T, MemoryPolicy >::reverse_iterator = std::reverse_iterator<iterator> |
◆ size_type
using immer::array< T, MemoryPolicy >::size_type = std::size_t |
◆ transient_type
using immer::array< T, MemoryPolicy >::transient_type = array_transient<T, MemoryPolicy> |
◆ value_type
using immer::array< T, MemoryPolicy >::value_type = T |
Constructor & Destructor Documentation
◆ array() [1/5]
|
default |
Default constructor. It creates an array of size() == 0
. It does not allocate memory and its complexity is .
◆ array() [2/5]
|
inline |
◆ array() [3/5]
|
inline |
◆ array() [4/5]
|
inline |
◆ array() [5/5]
|
inlineprivate |
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 167 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
◆ back()
|
inline |
Access the last element.
Definition at line 145 of file array.hpp.
References immer::array< T, MemoryPolicy >::data(), and immer::array< T, MemoryPolicy >::size().
◆ 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 103 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
Referenced by immer::array< T, MemoryPolicy >::rend().
◆ data()
|
inline |
Access the raw data.
Definition at line 140 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
Referenced by immer::array< T, MemoryPolicy >::back(), and immer::array< T, MemoryPolicy >::front().
◆ empty()
|
inline |
Returns true
if there are no elements in the container. It does not allocate memory and its complexity is .
Definition at line 135 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
◆ 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 109 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
Referenced by immer::array< T, MemoryPolicy >::rbegin().
◆ front()
|
inline |
Access the first element.
Definition at line 150 of file array.hpp.
References immer::array< T, MemoryPolicy >::data().
◆ impl()
|
inline |
Definition at line 278 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
◆ operator!=()
|
inline |
◆ operator==()
|
inline |
Returns whether the vectors are equal.
Definition at line 173 of file array.hpp.
References immer::array< T, MemoryPolicy >::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 158 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
◆ push_back() [1/2]
|
inline |
Returns an array with value
inserted at the end. It may allocate memory and its complexity is .
Example .. literalinclude:: ../example/array/array.cpp :language: c++ :dedent: 8 :start-after: push-back/start :end-before: push-back/end
Definition at line 193 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
◆ push_back() [2/2]
|
inline |
Definition at line 196 of file array.hpp.
References immer::array< T, MemoryPolicy >::push_back_move().
◆ push_back_move() [1/2]
|
inlineprivate |
Definition at line 285 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
Referenced by immer::array< T, MemoryPolicy >::push_back().
◆ push_back_move() [2/2]
|
inlineprivate |
Definition at line 287 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
◆ 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 116 of file array.hpp.
References immer::array< T, MemoryPolicy >::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 123 of file array.hpp.
References immer::array< T, MemoryPolicy >::begin().
◆ set() [1/2]
|
inline |
Returns an array containing value value
at position idx
. Undefined for index >= size()
. It may allocate memory and its complexity is .
Example .. literalinclude:: ../example/array/array.cpp :language: c++ :dedent: 8 :start-after: set/start :end-before: set/end
Definition at line 215 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
◆ set() [2/2]
|
inline |
Definition at line 218 of file array.hpp.
References immer::array< T, MemoryPolicy >::set_move().
◆ set_move() [1/2]
|
inlineprivate |
Definition at line 290 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
Referenced by immer::array< T, MemoryPolicy >::set().
◆ set_move() [2/2]
|
inlineprivate |
Definition at line 292 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
◆ size()
|
inline |
Returns the number of elements in the container. It does not allocate memory and its complexity is .
Definition at line 129 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
Referenced by immer::array< T, MemoryPolicy >::back().
◆ take() [1/2]
|
inline |
Returns a array containing only the first min(elems, size())
elements. It may allocate memory and its complexity is effectively .
Example .. literalinclude:: ../example/array/array.cpp :language: c++ :dedent: 8 :start-after: take/start :end-before: take/end
Definition at line 262 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
◆ take() [2/2]
|
inline |
Definition at line 265 of file array.hpp.
References immer::array< T, MemoryPolicy >::take_move().
◆ take_move() [1/2]
|
inlineprivate |
Definition at line 302 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
Referenced by immer::array< T, MemoryPolicy >::take().
◆ take_move() [2/2]
|
inlineprivate |
Definition at line 304 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
◆ transient() [1/2]
|
inline |
Returns an transient form of this container, an immer::array_transient
.
Definition at line 272 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
◆ transient() [2/2]
|
inline |
Definition at line 274 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
◆ update() [1/2]
|
inline |
Returns an array containing the result of the expression fn((*this)[idx])
at position idx
. Undefined for index >= size()
. It may allocate memory and its complexity is .
Example .. literalinclude:: ../example/array/array.cpp :language: c++ :dedent: 8 :start-after: update/start :end-before: update/end
Definition at line 239 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
◆ update() [2/2]
|
inline |
Definition at line 243 of file array.hpp.
References immer::array< T, MemoryPolicy >::update_move().
◆ update_move() [1/2]
|
inlineprivate |
Definition at line 296 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
Referenced by immer::array< T, MemoryPolicy >::update().
◆ update_move() [2/2]
|
inlineprivate |
Definition at line 299 of file array.hpp.
References immer::array< T, MemoryPolicy >::impl_.
Member Data Documentation
◆ impl_
|
private |
Definition at line 307 of file array.hpp.
Referenced by immer::array< T, MemoryPolicy >::at(), immer::array< T, MemoryPolicy >::begin(), immer::array< T, MemoryPolicy >::data(), immer::array< T, MemoryPolicy >::empty(), immer::array< T, MemoryPolicy >::end(), immer::array< T, MemoryPolicy >::impl(), immer::array< T, MemoryPolicy >::operator==(), immer::array< T, MemoryPolicy >::operator[](), immer::array< T, MemoryPolicy >::push_back(), immer::array< T, MemoryPolicy >::push_back_move(), immer::array< T, MemoryPolicy >::set(), immer::array< T, MemoryPolicy >::set_move(), immer::array< T, MemoryPolicy >::size(), immer::array< T, MemoryPolicy >::take(), immer::array< T, MemoryPolicy >::take_move(), immer::array< T, MemoryPolicy >::transient(), immer::array< T, MemoryPolicy >::update(), and immer::array< T, MemoryPolicy >::update_move().
◆ transient_type
|
private |
The documentation for this class was generated from the following file:
- src/immer/array.hpp