jaulib v1.3.0
Jau Support Library (C++, Java, ..)
Public Types | Public Member Functions | Static Public Attributes | List of all members
jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem > Class Template Reference

Implementation of a dynamic linear array storage, aka vector. More...

#include <darray.hpp>

Inheritance diagram for jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >:
Collaboration diagram for jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >:

Public Types

typedef Alloc_type allocator_type
 
typedef const value_typeconst_iterator
 
typedef const value_typeconst_pointer
 
typedef const value_typeconst_reference
 
typedef bool darray_tag
 Used to determine whether this type is a darray or has a darray, see ::is_darray_type<T> More...
 
typedef std::make_signed< size_type >::type difference_type
 
typedef bool(* equal_comparator) (const value_type &a, const value_type &b)
 Generic value_type equal comparator to be user defined for e.g. More...
 
typedef value_typeiterator
 
typedef value_typepointer
 
typedef value_typereference
 
typedef Size_type size_type
 
typedef Value_type value_type
 

Public Member Functions

constexpr darray () noexcept
 Default constructor, giving zero capacity and zero memory footprint. More...
 
constexpr darray (const darray &x)
 Creates a new instance, copying all elements from the given darray. More...
 
constexpr darray (const darray &x, const float growth_factor, const allocator_type &alloc)
 Creates a new instance, copying all elements from the given darray. More...
 
constexpr darray (const darray &x, const size_type _capacity, const float growth_factor, const allocator_type &alloc)
 Creates a new instance with custom initial storage capacity, copying all elements from the given darray. More...
 
constexpr darray (const size_type _capacity, const_iterator first, const_iterator last, const float growth_factor=DEFAULT_GROWTH_FACTOR, const allocator_type &alloc=allocator_type())
 Creates a new instance with custom initial storage capacity, copying all elements from the given const_iterator value_type range [first, last). More...
 
template<class InputIt >
constexpr darray (const size_type _capacity, InputIt first, InputIt last, const float growth_factor=DEFAULT_GROWTH_FACTOR, const allocator_type &alloc=allocator_type())
 Creates a new instance with custom initial storage capacity, copying all elements from the given template input-iterator value_type range [first, last). More...
 
constexpr darray (darray &&x) noexcept
 
constexpr darray (darray &&x, const float growth_factor, const allocator_type &alloc) noexcept
 
template<class InputIt >
constexpr darray (InputIt first, InputIt last, const allocator_type &alloc=allocator_type())
 Creates a new instance, copying all elements from the given template input-iterator value_type range [first, last). More...
 
constexpr darray (size_type capacity, const float growth_factor=DEFAULT_GROWTH_FACTOR, const allocator_type &alloc=allocator_type())
 Creating an empty instance with initial capacity and other (default) properties. More...
 
constexpr darray (std::initializer_list< value_type > initlist, const allocator_type &alloc=allocator_type())
 Create a new instance from an initializer list. More...
 
 ~darray () noexcept
 
constexpr void assign (const_iterator first, const_iterator last)
 Like std::vector::assign(), but non-template overload using const_iterator. More...
 
template<class InputIt >
constexpr void assign (InputIt first, InputIt last)
 Like std::vector::assign() More...
 
reference at (size_type i)
 Like std::vector::at(size_type), mutable reference. More...
 
const_reference at (size_type i) const
 Like std::vector::at(size_type), immutable reference. More...
 
constexpr reference back ()
 Like std::vector::back(), mutable access. More...
 
constexpr const_reference back () const
 Like std::vector::back(), immutable access. More...
 
constexpr const_iterator begin () const noexcept
 
constexpr iterator begin () noexcept
 
constexpr size_type capacity () const noexcept
 Return the current capacity. More...
 
constexpr bool capacity_reached () const noexcept
 Returns true if capacity has been reached and the next push_back() will grow the storage and invalidates all iterators and references. More...
 
constexpr const_iterator cbegin () const noexcept
 
constexpr const_iterator cend () const noexcept
 
constexpr void clear () noexcept
 Like std::vector::clear(), but ending with zero capacity. More...
 
constexpr const_pointer data () const noexcept
 Like std::vector::data(), const immutable pointer. More...
 
constexpr pointer data () noexcept
 Like std::vector::data(), mutable pointer. More...
 
template<typename... Args>
constexpr iterator emplace (const_iterator pos, Args &&... args)
 Like std::vector::emplace(), construct a new element in place. More...
 
template<typename... Args>
constexpr reference emplace_back (Args &&... args)
 Like std::vector::emplace_back(), construct a new element in place at the end(). More...
 
constexpr bool empty () const noexcept
 Like std::vector::empty(). More...
 
constexpr const_iterator end () const noexcept
 
constexpr iterator end () noexcept
 
constexpr iterator erase (const size_type first_idx, const size_type last_idx)
 Similar to std::vector::erase() using indices, removes the elements in the range [first_idx, last_idx). More...
 
constexpr iterator erase (const size_type pos_idx)
 Similar to std::vector::erase() using an index, removes the elements at pos_idx. More...
 
constexpr iterator erase (const_iterator pos)
 Like std::vector::erase(), removes the elements at pos. More...
 
constexpr iterator erase (iterator first, const_iterator last)
 Like std::vector::erase(), removes the elements in the range [first, last). More...
 
constexpr size_type erase_matching (const value_type &x, const bool all_matching, equal_comparator comparator)
 Erase either the first matching element or all matching elements. More...
 
constexpr reference front ()
 Like std::vector::front(), mutable access. More...
 
constexpr const_reference front () const
 Like std::vector::front(), immutable access. More...
 
allocator_type get_allocator () const noexcept
 
const allocator_typeget_allocator_ref () const noexcept
 
constexpr size_type get_grown_capacity () const noexcept
 Return the current capacity() multiplied by the growth factor, minimum is max(capacity()+1, 10). More...
 
std::string get_info () const noexcept
 
constexpr float growth_factor () const noexcept
 
constexpr iterator insert (const size_type pos_idx, const value_type &x)
 Similar to std::vector::insert() using an index, copy. More...
 
constexpr iterator insert (const_iterator pos, const value_type &x)
 Like std::vector::insert(), copy. More...
 
template<class InputIt >
constexpr iterator insert (const_iterator pos, InputIt first, InputIt last)
 Like std::vector::insert(), inserting the value_type range [first, last). More...
 
constexpr iterator insert (const_iterator pos, value_type &&x)
 Like std::vector::insert(), move. More...
 
constexpr size_type max_size () const noexcept
 Returns std::numeric_limits<difference_type>::max() as the maximum array size. More...
 
constexpr darrayoperator= (const darray &x)
 Like std::vector::operator=(&), assignment. More...
 
constexpr darrayoperator= (darray &&x) noexcept
 Like std::vector::operator=(&&), move. More...
 
const_reference operator[] (size_type i) const noexcept
 Like std::vector::operator[](size_type), immutable reference. More...
 
reference operator[] (size_type i) noexcept
 Like std::vector::operator[](size_type), mutable reference. More...
 
constexpr void pop_back () noexcept
 Like std::vector::pop_back(). More...
 
constexpr void push_back (const value_type &x)
 Like std::vector::push_back(), copy. More...
 
template<class InputIt >
constexpr void push_back (InputIt first, InputIt last)
 Like std::vector::push_back(), but appends the value_type range [first, last). More...
 
constexpr void push_back (value_type &&x)
 Like std::vector::push_back(), move. More...
 
template<typename... Args>
constexpr void push_back_list (Args &&... args)
 Like push_back(), but for more multiple r-value references to move. More...
 
template<typename... Args>
constexpr void push_back_list (const Args &... args)
 Like push_back(), but for more multiple const r-value to copy. More...
 
constexpr bool push_back_unique (const value_type &x, equal_comparator comparator)
 Like std::vector::push_back(), but only if the newly added element does not yet exist. More...
 
constexpr void push_front (const value_type &x)
 Like std::vector::push_front(), copy. More...
 
constexpr void push_front (value_type &&x)
 Like std::vector::push_front(), move. More...
 
void reserve (size_type new_capacity)
 Like std::vector::reserve(), increases this instance's capacity to new_capacity. More...
 
constexpr void shrink_to_fit ()
 Like std::vector::shrink_to_fit(), but ensured constexpr. More...
 
constexpr size_type size () const noexcept
 Like std::vector::size(). More...
 
constexpr void swap (darray &x) noexcept
 Like std::vector::swap(). More...
 
std::string toString () const noexcept
 

Static Public Attributes

static constexpr const float DEFAULT_GROWTH_FACTOR = 1.618f
 Default growth factor using the golden ratio 1.618. More...
 
static constexpr const bool uses_memmove = use_memmove
 
static constexpr const bool uses_realloc = use_memmove && std::is_base_of_v<jau::callocator<Value_type>, Alloc_type>
 
static constexpr const bool uses_secmem = use_secmem
 

Detailed Description

template<typename Value_type, typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
class jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >

Implementation of a dynamic linear array storage, aka vector.


Goals are to support a high-performance CoW dynamic array implementation, jau::cow_darray,
exposing fine grained control over its underlying storage facility.
Further, jau::darray provides high-performance and efficient storage properties on its own.

This class shall be compliant with C++ named requirements for Container.

API and design differences to std::vector

Implementation differences to std::vector and some details

Non-Type Template Parameter (NTTP) controlling Value_type memory

use_memmove

use_memmove can be overriden and defaults to std::is_trivially_copyable_v<Value_type>.

The default value has been chosen with care, see C++ Standard section 6.9 Types TriviallyCopyable.

See Trivial destructor being key requirement to TriviallyCopyable.

‍A trivial destructor is a destructor that performs no action. Objects with trivial destructors don't require a delete-expression and may be disposed of by simply deallocating their storage. All data types compatible with the C language (POD types) are trivially destructible.`

However, since the destructor is not being called when using memmove on elements within this container, the requirements are more relaxed and TriviallyCopyable not required nor guaranteed, see below.

memmove will be used to move an object inside this container memory only, i.e. where construction and destruction is controlled. Not requiring TriviallyCopyable constraints memmove as follows:

Relaxed requirements for use_memmove are:

Since element pointer and iterator are always invalidated for container after storage mutation, above constraints are not really anything novel and go along with normal std::vector.

Users may include typedef container_memmove_compliant in their Value_type class to enforce use_memmove as follows:

use_secmem

use_secmem can be overriden and defaults to false.

use_secmem, if enabled, ensures that the underlying memory will be zeroed out after use and element erasure.

Users may include typedef enforce_secmem in their Value_type class to enforce use_secmem as follows:

See also
cow_darray
Examples
test_cow_iterator_01.cpp.

Definition at line 147 of file darray.hpp.

Member Typedef Documentation

◆ value_type

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
typedef Value_type jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::value_type

Definition at line 159 of file darray.hpp.

◆ pointer

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
typedef value_type* jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::pointer

Definition at line 160 of file darray.hpp.

◆ const_pointer

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
typedef const value_type* jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::const_pointer

Definition at line 161 of file darray.hpp.

◆ reference

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
typedef value_type& jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::reference

Definition at line 162 of file darray.hpp.

◆ const_reference

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
typedef const value_type& jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::const_reference

Definition at line 163 of file darray.hpp.

◆ iterator

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
typedef value_type* jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::iterator

Definition at line 164 of file darray.hpp.

◆ const_iterator

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
typedef const value_type* jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::const_iterator

Definition at line 165 of file darray.hpp.

◆ size_type

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
typedef Size_type jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::size_type

Definition at line 166 of file darray.hpp.

◆ difference_type

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
typedef std::make_signed<size_type>::type jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::difference_type

Definition at line 167 of file darray.hpp.

◆ allocator_type

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
typedef Alloc_type jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::allocator_type

Definition at line 170 of file darray.hpp.

◆ darray_tag

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
typedef bool jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::darray_tag

Used to determine whether this type is a darray or has a darray, see ::is_darray_type<T>

Definition at line 173 of file darray.hpp.

◆ equal_comparator

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
typedef bool(* jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::equal_comparator) (const value_type &a, const value_type &b)

Generic value_type equal comparator to be user defined for e.g.

jau::darray::push_back_unique().

Parameters
aone element of the equality test.
bthe other element of the equality test.
Returns
true if both are equal

Definition at line 1249 of file darray.hpp.

Constructor & Destructor Documentation

◆ darray() [1/11]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::darray ( )
inlineconstexprnoexcept

Default constructor, giving zero capacity and zero memory footprint.

Definition at line 474 of file darray.hpp.

◆ darray() [2/11]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::darray ( size_type  capacity,
const float  growth_factor = DEFAULT_GROWTH_FACTOR,
const allocator_type alloc = allocator_type() 
)
inlineexplicitconstexpr

Creating an empty instance with initial capacity and other (default) properties.

Parameters
capacityinitial capacity of the new instance.
growth_factorgiven growth factor
allocgiven allocator_type

Definition at line 486 of file darray.hpp.

◆ darray() [3/11]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::darray ( const darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem > &  x)
inlineconstexpr

Creates a new instance, copying all elements from the given darray.


Capacity and size will equal the given array, i.e. the result is a trimmed jau::darray.

Parameters
xthe given darray, all elements will be copied into the new instance.

Definition at line 499 of file darray.hpp.

◆ darray() [4/11]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::darray ( const darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem > &  x,
const float  growth_factor,
const allocator_type alloc 
)
inlineexplicitconstexpr

Creates a new instance, copying all elements from the given darray.


Capacity and size will equal the given array, i.e. the result is a trimmed jau::darray.

Parameters
xthe given darray, all elements will be copied into the new instance.
growth_factorcustom growth factor
alloccustom allocator_type instance

Definition at line 513 of file darray.hpp.

◆ darray() [5/11]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::darray ( const darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem > &  x,
const size_type  _capacity,
const float  growth_factor,
const allocator_type alloc 
)
inlineexplicitconstexpr

Creates a new instance with custom initial storage capacity, copying all elements from the given darray.


Size will equal the given array.

Throws jau::IllegalArgumentException() if _capacity < x.size().

Parameters
xthe given darray, all elements will be copied into the new instance.
_capacitycustom initial storage capacity
growth_factorcustom growth factor
alloccustom allocator_type instance

Definition at line 531 of file darray.hpp.

◆ darray() [6/11]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::darray ( darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem > &&  x)
inlineconstexprnoexcept

Definition at line 565 of file darray.hpp.

◆ darray() [7/11]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::darray ( darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem > &&  x,
const float  growth_factor,
const allocator_type alloc 
)
inlineexplicitconstexprnoexcept

Definition at line 575 of file darray.hpp.

◆ darray() [8/11]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::darray ( const size_type  _capacity,
const_iterator  first,
const_iterator  last,
const float  growth_factor = DEFAULT_GROWTH_FACTOR,
const allocator_type alloc = allocator_type() 
)
inlineexplicitconstexpr

Creates a new instance with custom initial storage capacity, copying all elements from the given const_iterator value_type range [first, last).


Size will equal the range [first, last), i.e. size_type(last-first).

Throws jau::IllegalArgumentException() if _capacity < size_type(last - first).

Parameters
_capacitycustom initial storage capacity
firstconst_iterator to first element of value_type range [first, last)
lastconst_iterator to last element of value_type range [first, last)
growth_factorcustom growth factor
alloccustom allocator_type instance

Definition at line 622 of file darray.hpp.

◆ darray() [9/11]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
template<class InputIt >
constexpr jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::darray ( const size_type  _capacity,
InputIt  first,
InputIt  last,
const float  growth_factor = DEFAULT_GROWTH_FACTOR,
const allocator_type alloc = allocator_type() 
)
inlineexplicitconstexpr

Creates a new instance with custom initial storage capacity, copying all elements from the given template input-iterator value_type range [first, last).


Size will equal the range [first, last), i.e. size_type(last-first).

Throws jau::IllegalArgumentException() if _capacity < size_type(last - first).

Template Parameters
InputIttemplate input-iterator custom type
Parameters
_capacitycustom initial storage capacity
firsttemplate input-iterator to first element of value_type range [first, last)
lasttemplate input-iterator to last element of value_type range [first, last)
growth_factorcustom growth factor
alloccustom allocator_type instance

Definition at line 644 of file darray.hpp.

◆ darray() [10/11]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
template<class InputIt >
constexpr jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::darray ( InputIt  first,
InputIt  last,
const allocator_type alloc = allocator_type() 
)
inlineconstexpr

Creates a new instance, copying all elements from the given template input-iterator value_type range [first, last).


Size will equal the range [first, last), i.e. size_type(last-first).

Template Parameters
InputIttemplate input-iterator custom type
Parameters
firsttemplate input-iterator to first element of value_type range [first, last)
lasttemplate input-iterator to last element of value_type range [first, last)
alloccustom allocator_type instance

Definition at line 661 of file darray.hpp.

◆ darray() [11/11]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::darray ( std::initializer_list< value_type initlist,
const allocator_type alloc = allocator_type() 
)
inlineconstexpr

Create a new instance from an initializer list.

Using the std::initializer_list requires to copy the given value_type objects into this darray.

To utilize more efficient move semantics, see push_back_list() and jau::make_darray().

Parameters
initlistinitializer_list.
allocallocator
See also
push_back_list()
jau::make_darray()

Definition at line 679 of file darray.hpp.

◆ ~darray()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::~darray ( )
inlinenoexcept

Definition at line 685 of file darray.hpp.

Member Function Documentation

◆ operator=() [1/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr darray & jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::operator= ( const darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem > &  x)
inlineconstexpr

Like std::vector::operator=(&), assignment.

Definition at line 541 of file darray.hpp.

Here is the caller graph for this function:

◆ operator=() [2/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr darray & jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::operator= ( darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem > &&  x)
inlineconstexprnoexcept

Like std::vector::operator=(&&), move.

Definition at line 588 of file darray.hpp.

◆ max_size()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr size_type jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::max_size ( ) const
inlineconstexprnoexcept

Returns std::numeric_limits<difference_type>::max() as the maximum array size.

We rely on the signed difference_type for pointer arithmetic, deducing ranges from iterator.

Definition at line 697 of file darray.hpp.

◆ begin() [1/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr iterator jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::begin ( )
inlineconstexprnoexcept

Definition at line 701 of file darray.hpp.

Here is the caller graph for this function:

◆ begin() [2/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr const_iterator jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::begin ( ) const
inlineconstexprnoexcept

Definition at line 703 of file darray.hpp.

◆ cbegin()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr const_iterator jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::cbegin ( ) const
inlineconstexprnoexcept

Definition at line 705 of file darray.hpp.

Here is the caller graph for this function:

◆ end() [1/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr iterator jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::end ( )
inlineconstexprnoexcept

Definition at line 707 of file darray.hpp.

Here is the caller graph for this function:

◆ end() [2/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr const_iterator jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::end ( ) const
inlineconstexprnoexcept

Definition at line 709 of file darray.hpp.

◆ cend()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr const_iterator jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::cend ( ) const
inlineconstexprnoexcept

Definition at line 711 of file darray.hpp.

Here is the caller graph for this function:

◆ get_allocator_ref()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
const allocator_type & jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::get_allocator_ref ( ) const
inlinenoexcept

Definition at line 723 of file darray.hpp.

◆ get_allocator()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
allocator_type jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::get_allocator ( ) const
inlinenoexcept

Definition at line 727 of file darray.hpp.

◆ growth_factor()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr float jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::growth_factor ( ) const
inlineconstexprnoexcept

Definition at line 731 of file darray.hpp.

Here is the caller graph for this function:

◆ capacity()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr size_type jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::capacity ( ) const
inlineconstexprnoexcept

Return the current capacity.

Definition at line 738 of file darray.hpp.

Here is the caller graph for this function:

◆ get_grown_capacity()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr size_type jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::get_grown_capacity ( ) const
inlineconstexprnoexcept

Return the current capacity() multiplied by the growth factor, minimum is max(capacity()+1, 10).

Definition at line 743 of file darray.hpp.

◆ empty()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr bool jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::empty ( ) const
inlineconstexprnoexcept

Like std::vector::empty().

Definition at line 752 of file darray.hpp.

◆ capacity_reached()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr bool jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::capacity_reached ( ) const
inlineconstexprnoexcept

Returns true if capacity has been reached and the next push_back() will grow the storage and invalidates all iterators and references.

Definition at line 758 of file darray.hpp.

◆ size()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr size_type jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::size ( ) const
inlineconstexprnoexcept

Like std::vector::size().

Definition at line 763 of file darray.hpp.

Here is the caller graph for this function:

◆ front() [1/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr reference jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::front ( )
inlineconstexpr

Like std::vector::front(), mutable access.

Definition at line 770 of file darray.hpp.

◆ front() [2/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr const_reference jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::front ( ) const
inlineconstexpr

Like std::vector::front(), immutable access.

Definition at line 775 of file darray.hpp.

◆ back() [1/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr reference jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::back ( )
inlineconstexpr

Like std::vector::back(), mutable access.

Definition at line 780 of file darray.hpp.

◆ back() [2/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr const_reference jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::back ( ) const
inlineconstexpr

Like std::vector::back(), immutable access.

Definition at line 785 of file darray.hpp.

◆ data() [1/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr const_pointer jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::data ( ) const
inlineconstexprnoexcept

Like std::vector::data(), const immutable pointer.

Definition at line 790 of file darray.hpp.

◆ data() [2/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr pointer jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::data ( )
inlineconstexprnoexcept

Like std::vector::data(), mutable pointer.

Definition at line 795 of file darray.hpp.

◆ operator[]() [1/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
const_reference jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::operator[] ( size_type  i) const
inlinenoexcept

Like std::vector::operator[](size_type), immutable reference.

Definition at line 800 of file darray.hpp.

◆ operator[]() [2/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
reference jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::operator[] ( size_type  i)
inlinenoexcept

Like std::vector::operator[](size_type), mutable reference.

Definition at line 807 of file darray.hpp.

◆ at() [1/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
const_reference jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::at ( size_type  i) const
inline

Like std::vector::at(size_type), immutable reference.

Definition at line 814 of file darray.hpp.

Here is the caller graph for this function:

◆ at() [2/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
reference jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::at ( size_type  i)
inline

Like std::vector::at(size_type), mutable reference.

Definition at line 824 of file darray.hpp.

◆ reserve()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
void jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::reserve ( size_type  new_capacity)
inline

Like std::vector::reserve(), increases this instance's capacity to new_capacity.

Only creates a new storage and invalidates iterators if new_capacity is greater than the current jau::darray::capacity().

Definition at line 840 of file darray.hpp.

◆ shrink_to_fit()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr void jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::shrink_to_fit ( )
inlineconstexpr

Like std::vector::shrink_to_fit(), but ensured constexpr.

If capacity() > size(), reallocate storage to size().

Definition at line 852 of file darray.hpp.

◆ assign() [1/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
template<class InputIt >
constexpr void jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::assign ( InputIt  first,
InputIt  last 
)
inlineconstexpr

Like std::vector::assign()

Template Parameters
InputItforeign input-iterator to range of value_type [first, last)
Parameters
firstfirst foreign input-iterator to range of value_type [first, last)
lastlast foreign input-iterator to range of value_type [first, last)

Definition at line 867 of file darray.hpp.

◆ assign() [2/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr void jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::assign ( const_iterator  first,
const_iterator  last 
)
inlineconstexpr

Like std::vector::assign(), but non-template overload using const_iterator.

Parameters
firstfirst const_iterator to range of value_type [first, last)
lastlast const_iterator to range of value_type [first, last)

Definition at line 886 of file darray.hpp.

◆ clear()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr void jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::clear ( )
inlineconstexprnoexcept

Like std::vector::clear(), but ending with zero capacity.

Definition at line 904 of file darray.hpp.

Here is the caller graph for this function:

◆ swap()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr void jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::swap ( darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem > &  x)
inlineconstexprnoexcept

Like std::vector::swap().

Definition at line 915 of file darray.hpp.

◆ pop_back()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr void jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::pop_back ( )
inlineconstexprnoexcept

Like std::vector::pop_back().

Definition at line 930 of file darray.hpp.

◆ erase() [1/4]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr iterator jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::erase ( const_iterator  pos)
inlineconstexpr

Like std::vector::erase(), removes the elements at pos.

Returns
iterator following the last removed element.

Definition at line 940 of file darray.hpp.

Here is the caller graph for this function:

◆ erase() [2/4]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr iterator jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::erase ( iterator  first,
const_iterator  last 
)
inlineconstexpr

Like std::vector::erase(), removes the elements in the range [first, last).

Returns
iterator following the last removed element.

Definition at line 956 of file darray.hpp.

◆ erase() [3/4]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr iterator jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::erase ( const size_type  pos_idx)
inlineconstexpr

Similar to std::vector::erase() using an index, removes the elements at pos_idx.

Returns
iterator following the last removed element.

Definition at line 972 of file darray.hpp.

◆ erase() [4/4]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr iterator jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::erase ( const size_type  first_idx,
const size_type  last_idx 
)
inlineconstexpr

Similar to std::vector::erase() using indices, removes the elements in the range [first_idx, last_idx).

Returns
iterator following the last removed element.

Definition at line 980 of file darray.hpp.

◆ insert() [1/4]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr iterator jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::insert ( const_iterator  pos,
const value_type x 
)
inlineconstexpr

Like std::vector::insert(), copy.

Inserts the element before pos and moves all elements from there to the right beforehand.

size will be increased by one.

Parameters
positerator before which the content will be inserted. pos may be the end() iterator
xelement value to insert

Definition at line 996 of file darray.hpp.

Here is the caller graph for this function:

◆ insert() [2/4]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr iterator jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::insert ( const size_type  pos_idx,
const value_type x 
)
inlineconstexpr

Similar to std::vector::insert() using an index, copy.

Parameters
pos_idxindex before which the content will be inserted. index may be the end size() index
xelement value to insert

Definition at line 1021 of file darray.hpp.

◆ insert() [3/4]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr iterator jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::insert ( const_iterator  pos,
value_type &&  x 
)
inlineconstexpr

Like std::vector::insert(), move.

Inserts the element before the given position and moves all elements from there to the right beforehand.

size will be increased by one.

Parameters
positerator before which the content will be inserted. pos may be the end() iterator
xelement value to be moved into

Definition at line 1037 of file darray.hpp.

◆ emplace()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
template<typename... Args>
constexpr iterator jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::emplace ( const_iterator  pos,
Args &&...  args 
)
inlineconstexpr

Like std::vector::emplace(), construct a new element in place.

Constructs the element before the given position using placement new and moves all elements from there to the right beforehand.

size will be increased by one.

Parameters
positerator before which the content will be inserted. pos may be the end() iterator
argsarguments to forward to the constructor of the element

Definition at line 1070 of file darray.hpp.

◆ insert() [4/4]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
template<class InputIt >
constexpr iterator jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::insert ( const_iterator  pos,
InputIt  first,
InputIt  last 
)
inlineconstexpr

Like std::vector::insert(), inserting the value_type range [first, last).

Template Parameters
InputItforeign input-iterator to range of value_type [first, last)
Parameters
positerator before which the content will be inserted. pos may be the end() iterator
firstfirst foreign input-iterator to range of value_type [first, last)
lastlast foreign input-iterator to range of value_type [first, last)
Returns
Iterator pointing to the first element inserted, or pos if first==last.

Definition at line 1099 of file darray.hpp.

◆ push_back() [1/3]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr void jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::push_back ( const value_type x)
inlineconstexpr

Like std::vector::push_back(), copy.

Parameters
xthe value to be added at the tail.

Definition at line 1124 of file darray.hpp.

Here is the caller graph for this function:

◆ push_back() [2/3]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr void jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::push_back ( value_type &&  x)
inlineconstexpr

Like std::vector::push_back(), move.

Parameters
xthe value to be added at the tail.

Definition at line 1136 of file darray.hpp.

◆ push_front() [1/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr void jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::push_front ( const value_type x)
inlineconstexpr

Like std::vector::push_front(), copy.

Parameters
xthe value to be added at the front.

Definition at line 1148 of file darray.hpp.

◆ push_front() [2/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr void jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::push_front ( value_type &&  x)
inlineconstexpr

Like std::vector::push_front(), move.

Parameters
xthe value to be added at the front.

Definition at line 1156 of file darray.hpp.

◆ emplace_back()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
template<typename... Args>
constexpr reference jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::emplace_back ( Args &&...  args)
inlineconstexpr

Like std::vector::emplace_back(), construct a new element in place at the end().

Constructs the element at the end() using placement new.

size will be increased by one.

Parameters
argsarguments to forward to the constructor of the element

Definition at line 1171 of file darray.hpp.

◆ push_back() [3/3]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
template<class InputIt >
constexpr void jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::push_back ( InputIt  first,
InputIt  last 
)
inlineconstexpr

Like std::vector::push_back(), but appends the value_type range [first, last).

Template Parameters
InputItforeign input-iterator to range of value_type [first, last)
Parameters
firstfirst foreign input-iterator to range of value_type [first, last)
lastlast foreign input-iterator to range of value_type [first, last)

Definition at line 1188 of file darray.hpp.

◆ push_back_list() [1/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
template<typename... Args>
constexpr void jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::push_back_list ( const Args &...  args)
inlineconstexpr

Like push_back(), but for more multiple const r-value to copy.

Template Parameters
Args
Parameters
argsr-value references to copy into this storage

Definition at line 1205 of file darray.hpp.

Here is the caller graph for this function:

◆ push_back_list() [2/2]

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
template<typename... Args>
constexpr void jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::push_back_list ( Args &&...  args)
inlineconstexpr

Like push_back(), but for more multiple r-value references to move.

Template Parameters
Args
Parameters
argsr-value references to move into this storage
See also
jau::make_darray()

Definition at line 1228 of file darray.hpp.

◆ push_back_unique()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr bool jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::push_back_unique ( const value_type x,
equal_comparator  comparator 
)
inlineconstexpr

Like std::vector::push_back(), but only if the newly added element does not yet exist.

Examples

    static jau::darray<Thing>::equal_comparator thingEqComparator =
                 [](const Thing &a, const Thing &b) -> bool { return a == b; };
    ...
    jau::darray<Thing> list;

    bool added = list.push_back_unique(new_element, thingEqComparator);
    ...
    darray<std::shared_ptr<Thing>> listOfRefs;
    bool added = listOfRefs.push_back_unique(new_element,
                   [](const std::shared_ptr<Thing> &a, const std::shared_ptr<Thing> &b) -> bool { return *a == *b; });
Parameters
xthe value to be added at the tail, if not existing yet.
comparatorthe equal comparator to return true if both given elements are equal
Returns
true if the element has been uniquely added, otherwise false

Definition at line 1272 of file darray.hpp.

◆ erase_matching()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr size_type jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::erase_matching ( const value_type x,
const bool  all_matching,
equal_comparator  comparator 
)
inlineconstexpr

Erase either the first matching element or all matching elements.

Examples

    darray<Thing> list;
    int count = list.erase_matching(element, true,
                   [](const Thing &a, const Thing &b) -> bool { return a == b; });
    ...
    static jau::darray<Thing>::equal_comparator thingRefEqComparator =
                 [](const std::shared_ptr<Thing> &a, const std::shared_ptr<Thing> &b) -> bool { return *a == *b; };
    ...
    darray<std::shared_ptr<Thing>> listOfRefs;
    int count = listOfRefs.erase_matching(element, false, thingRefEqComparator);
Parameters
xthe value to be added at the tail, if not existing yet.
all_matchingif true, erase all matching elements, otherwise only the first matching element.
comparatorthe equal comparator to return true if both given elements are equal
Returns
number of erased elements

Definition at line 1305 of file darray.hpp.

◆ toString()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
std::string jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::toString ( ) const
inlinenoexcept

Definition at line 1319 of file darray.hpp.

Here is the caller graph for this function:

◆ get_info()

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
std::string jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::get_info ( ) const
inlinenoexcept

Definition at line 1330 of file darray.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ DEFAULT_GROWTH_FACTOR

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr const float jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::DEFAULT_GROWTH_FACTOR = 1.618f
staticconstexpr

Default growth factor using the golden ratio 1.618.

Definition at line 151 of file darray.hpp.

◆ uses_memmove

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr const bool jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::uses_memmove = use_memmove
staticconstexpr

Definition at line 153 of file darray.hpp.

◆ uses_secmem

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr const bool jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::uses_secmem = use_secmem
staticconstexpr

Definition at line 154 of file darray.hpp.

◆ uses_realloc

template<typename Value_type , typename Size_type = jau::nsize_t, typename Alloc_type = jau::callocator<Value_type>, bool use_memmove = std::is_trivially_copyable_v<Value_type> || is_container_memmove_compliant_v<Value_type>, bool use_secmem = is_enforcing_secmem_v<Value_type>>
constexpr const bool jau::darray< Value_type, Size_type, Alloc_type, use_memmove, use_secmem >::uses_realloc = use_memmove && std::is_base_of_v<jau::callocator<Value_type>, Alloc_type>
staticconstexpr

Definition at line 155 of file darray.hpp.


The documentation for this class was generated from the following file: