Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
Public Types | Public Member Functions | Friends | List of all members
jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container > Class Template Reference

Implementation of a Copy-On-Write (CoW) read-write iterator over mutable value_type storage. More...

#include <cow_iterator.hpp>

Collaboration diagram for jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >:

Public Types

typedef Storage_type storage_t
 
typedef Storage_ref_type storage_ref_t
 
typedef CoW_container cow_container_t
 
typedef storage_t::iterator iterator_type
 Actual iterator type of the contained native iterator, probably a simple pointer. More...
 
typedef sub_traits_t::iterator_category iterator_category
 
typedef storage_t::size_type size_type
 
typedef storage_t::difference_type difference_type
 
typedef sub_traits_t::value_type value_type
 
typedef sub_traits_t::reference reference
 
typedef sub_traits_t::pointer pointer
 

Public Member Functions

void write_back () noexcept
 Replace the parent's current store with this iterators' instance, unlock the CoW parents' write lock and discard all storage references. More...
 
constexpr cow_rw_iterator (const cow_rw_iterator &o) noexcept
 C++ named requirements: LegacyIterator: CopyConstructible. More...
 
constexpr cow_rw_iteratoroperator= (const cow_rw_iterator &o) noexcept
 Assigns content of other mutable iterator to this one, if they are not identical. More...
 
constexpr cow_rw_iterator (cow_rw_iterator &&o) noexcept
 C++ named requirements: LegacyIterator: MoveConstructable. More...
 
constexpr cow_rw_iteratoroperator= (cow_rw_iterator &&o) noexcept
 Assigns identity of given mutable iterator, if they are not identical. More...
 
void swap (cow_rw_iterator &o) noexcept
 C++ named requirements: LegacyIterator: Swappable. More...
 
constexpr cow_ro_iterator< Storage_type, Storage_ref_type, CoW_container > immutable () const noexcept
 Returns a new const_iterator pointing to the current position. More...
 
constexpr cow_rw_iterator begin () const noexcept
 Returns a new iterator pointing to the first element, aka begin. More...
 
constexpr cow_rw_iterator end () const noexcept
 Returns a new iterator pointing to the element following the last element, aka end. More...
 
constexpr bool empty () const noexcept
 Returns true if storage is empty(). More...
 
constexpr bool capacity_reached () const noexcept
 Returns true if storage capacity has been reached and the next push_back() will grow the storage and invalidates all iterators and references. More...
 
constexpr size_type size () const noexcept
 Return the size of the underlying value_type store. More...
 
constexpr storage_tstorage () const noexcept
 Returns this instances' underlying shared storage by reference. More...
 
constexpr difference_type dist_end () const noexcept
 Returns the distance to_end() using zero as first index. More...
 
constexpr bool is_end () const noexcept
 Returns true, if this iterator points to end(). More...
 
constexpr cow_rw_iteratorto_end () noexcept
 This iterator is set to the last element, end(). More...
 
constexpr difference_type dist_begin () const noexcept
 Returns the distance to_begin() using zero as first index. More...
 
constexpr bool is_begin () const noexcept
 Returns true, if this iterator points to begin(). More...
 
constexpr cow_rw_iteratorto_begin () noexcept
 This iterator is set to the first element, begin(). More...
 
constexpr iterator_type base () const noexcept
 Returns a copy of the underlying storage iterator. More...
 
constexpr int compare (const cow_rw_iterator &rhs) const noexcept
 Returns signum or three-way comparison value. More...
 
constexpr bool operator== (const cow_rw_iterator &rhs) const noexcept
 
constexpr bool operator!= (const cow_rw_iterator &rhs) const noexcept
 
constexpr bool operator<= (const cow_rw_iterator &rhs) const noexcept
 
constexpr bool operator< (const cow_rw_iterator &rhs) const noexcept
 
constexpr bool operator>= (const cow_rw_iterator &rhs) const noexcept
 
constexpr bool operator> (const cow_rw_iterator &rhs) const noexcept
 
constexpr const reference operator* () const noexcept
 Dereferencing iterator to value_type reference. More...
 
constexpr const pointer operator-> () const noexcept
 Pointer to member access. More...
 
constexpr reference operator* () noexcept
 Dereferencing iterator to value_type reference. More...
 
constexpr pointer operator-> () noexcept
 Pointer to member access. More...
 
constexpr cow_rw_iteratoroperator++ () noexcept
 Pre-increment; Well performing, return *this. More...
 
constexpr cow_rw_iterator operator++ (int) noexcept
 Post-increment; Try to avoid: Low performance due to returning copy-ctor. More...
 
constexpr cow_rw_iteratoroperator-- () noexcept
 Pre-decrement; Well performing, return *this. More...
 
constexpr cow_rw_iterator operator-- (int) noexcept
 Post-decrement; Try to avoid: Low performance due to returning copy-ctor. More...
 
constexpr const reference operator[] (difference_type i) const noexcept
 Subscript of 'element_index', returning immutable Value_type reference. More...
 
constexpr reference operator[] (difference_type i) noexcept
 Subscript of 'element_index', returning mutable Value_type reference. More...
 
constexpr cow_rw_iteratoroperator+= (difference_type i) noexcept
 Addition-assignment of 'element_count'; Well performing, return *this. More...
 
constexpr cow_rw_iterator operator+ (difference_type rhs) const noexcept
 Binary 'iterator + element_count'; Try to avoid: Low performance due to returning copy-ctor. More...
 
constexpr cow_rw_iteratoroperator-= (difference_type i) noexcept
 Subtraction-assignment of 'element_count'; Well performing, return *this. More...
 
constexpr cow_rw_iterator operator- (difference_type rhs) const noexcept
 Binary 'iterator - element_count'; Try to avoid: Low performance due to returning copy-ctor. More...
 
constexpr difference_type operator- (const cow_rw_iterator &rhs) const noexcept
 Binary 'iterator - iterator -> element_count'; Well performing, return element_count of type difference_type. More...
 
constexpr_cxx20 std::string toString () const noexcept
 
constexpr_cxx20 std::string get_info () const noexcept
 
constexpr void pop_back () noexcept
 Removes the last element and sets this iterator to end() More...
 
constexpr void erase ()
 Erases the element at the current position. More...
 
constexpr void erase (size_type count)
 Like std::vector::erase(), removes the elements in the range [current, current+count). More...
 
constexpr void insert (const value_type &x)
 Inserts the element before the current position and moves all elements from there to the right beforehand. More...
 
constexpr void insert (value_type &&x)
 Inserts the element before the current position (std::move operation) and moves all elements from there to the right beforehand. More...
 
template<typename... Args>
constexpr void emplace (Args &&... args)
 Like std::vector::emplace(), construct a new element in place. More...
 
template<class InputIt >
constexpr void insert (InputIt first, InputIt last)
 Like std::vector::insert(), inserting the value_type range [first, last). More...
 
constexpr void push_back (const value_type &x)
 Like std::vector::push_back(), copy. More...
 
constexpr void push_back (value_type &&x)
 Like std::vector::push_back(), move. 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...
 
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...
 

Friends

template<typename , typename , typename , bool , bool , bool >
class cow_darray
 
template<typename , typename >
class cow_vector
 

Detailed Description

template<typename Storage_type, typename Storage_ref_type, typename CoW_container>
class jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >

Implementation of a Copy-On-Write (CoW) read-write iterator over mutable value_type storage.


Instance holds a copy of the parents' CoW storage and locks its write mutex until write_back() or destruction.

Implementation complies with Type Traits iterator_category 'random_access_iterator_tag'

This iterator wraps the native iterator of type 'iterator_type' and manages the CoW related resource lifecycle.

After completing all mutable operations but before this iterator's destruction, the user might want to write back this iterators' storage to its parents' CoW using write_back()

Due to the costly nature of mutable CoW resource management, consider using jau::cow_ro_iterator if elements won't get mutated or any changes can be discarded.

To allow data-race free operations on this iterator's data copy from a potentially mutated CoW, only one begin iterator should be retrieved from CoW and all further operations shall use jau::cow_rw_iterator::size(), jau::cow_rw_iterator::begin() and jau::cow_rw_iterator::end().

See also
jau::cow_rw_iterator::write_back()
jau::for_each_fidelity
jau::cow_darray

Definition at line 47 of file cow_iterator.hpp.

Member Typedef Documentation

◆ cow_container_t

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
typedef CoW_container jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::cow_container_t

Definition at line 92 of file cow_iterator.hpp.

◆ difference_type

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
typedef storage_t::difference_type jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::difference_type

Definition at line 117 of file cow_iterator.hpp.

◆ iterator_category

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
typedef sub_traits_t::iterator_category jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::iterator_category

Definition at line 114 of file cow_iterator.hpp.

◆ iterator_type

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
typedef storage_t::iterator jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::iterator_type

Actual iterator type of the contained native iterator, probably a simple pointer.

Definition at line 95 of file cow_iterator.hpp.

◆ pointer

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
typedef sub_traits_t::pointer jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::pointer

Definition at line 123 of file cow_iterator.hpp.

◆ reference

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
typedef sub_traits_t::reference jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::reference

Definition at line 122 of file cow_iterator.hpp.

◆ size_type

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
typedef storage_t::size_type jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::size_type

Definition at line 116 of file cow_iterator.hpp.

◆ storage_ref_t

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
typedef Storage_ref_type jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::storage_ref_t

Definition at line 91 of file cow_iterator.hpp.

◆ storage_t

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
typedef Storage_type jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::storage_t

Definition at line 90 of file cow_iterator.hpp.

◆ value_type

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
typedef sub_traits_t::value_type jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::value_type

Definition at line 121 of file cow_iterator.hpp.

Constructor & Destructor Documentation

◆ cow_rw_iterator() [1/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::cow_rw_iterator ( const cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container > &  o)
inlineconstexprnoexcept

C++ named requirements: LegacyIterator: CopyConstructible.

Definition at line 166 of file cow_iterator.hpp.

◆ cow_rw_iterator() [2/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::cow_rw_iterator ( cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container > &&  o)
inlineconstexprnoexcept

C++ named requirements: LegacyIterator: MoveConstructable.

Definition at line 193 of file cow_iterator.hpp.

Member Function Documentation

◆ base()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr iterator_type jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::base ( ) const
inlineconstexprnoexcept

Returns a copy of the underlying storage iterator.

Definition at line 332 of file cow_iterator.hpp.

◆ begin()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr cow_rw_iterator jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::begin ( ) const
inlineconstexprnoexcept

Returns a new iterator pointing to the first element, aka begin.

This is an addition API entry, allowing data-race free operations on this iterator's data snapshot from a potentially mutated CoW.

See also
size()
end()

Definition at line 253 of file cow_iterator.hpp.

Here is the caller graph for this function:

◆ capacity_reached()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr bool jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::capacity_reached ( ) const
inlineconstexprnoexcept

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

Definition at line 277 of file cow_iterator.hpp.

◆ compare()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr int jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::compare ( const cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container > &  rhs) const
inlineconstexprnoexcept

Returns signum or three-way comparison value.

   0 if equal (both, store and iteratore),
  -1 if this->iterator_ < rhs_iter and
   1 if this->iterator_ > rhs_iter (otherwise)
Parameters
rhs_storeright-hand side store
rhs_iterright-hand side iterator

Definition at line 346 of file cow_iterator.hpp.

Here is the caller graph for this function:

◆ dist_begin()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr difference_type jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::dist_begin ( ) const
inlineconstexprnoexcept

Returns the distance to_begin() using zero as first index.

A.k.a the index from start.

Definition at line 316 of file cow_iterator.hpp.

◆ dist_end()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr difference_type jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::dist_end ( ) const
inlineconstexprnoexcept

Returns the distance to_end() using zero as first index.

A.k.a the remaining elements iterable.

Definition at line 300 of file cow_iterator.hpp.

◆ emplace()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
template<typename... Args>
constexpr void jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::emplace ( Args &&...  args)
inlineconstexpr

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

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

size will be increased by one.

This iterator is set to the inserted element.

Parameters
argsarguments to forward to the constructor of the element

Definition at line 545 of file cow_iterator.hpp.

◆ emplace_back()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
template<typename... Args>
constexpr reference jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::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.

This iterator is set to the end.

Parameters
argsarguments to forward to the constructor of the element

Definition at line 601 of file cow_iterator.hpp.

◆ empty()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr bool jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::empty ( ) const
inlineconstexprnoexcept

Returns true if storage is empty().

Definition at line 271 of file cow_iterator.hpp.

◆ end()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr cow_rw_iterator jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::end ( ) const
inlineconstexprnoexcept

Returns a new iterator pointing to the element following the last element, aka end.


This is an addition API entry, allowing data-race free operations on this iterator's data snapshot from a potentially mutated CoW.

See also
size()
begin()

Definition at line 265 of file cow_iterator.hpp.

Here is the caller graph for this function:

◆ erase() [1/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr void jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::erase ( )
inlineconstexpr

Erases the element at the current position.

This iterator is set to the element following the last removed element.

Definition at line 488 of file cow_iterator.hpp.

Here is the caller graph for this function:

◆ erase() [2/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr void jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::erase ( size_type  count)
inlineconstexpr

Like std::vector::erase(), removes the elements in the range [current, current+count).

This iterator is set to the element following the last removed element.

Definition at line 498 of file cow_iterator.hpp.

◆ get_info()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr_cxx20 std::string jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::get_info ( ) const
inlinenoexcept

Definition at line 468 of file cow_iterator.hpp.

◆ immutable()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr cow_ro_iterator<Storage_type, Storage_ref_type, CoW_container> jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::immutable ( ) const
inlineconstexprnoexcept

Returns a new const_iterator pointing to the current position.


This is the only explicit conversion operation of mutable -> immutable iterator, see below.

Be aware that the resulting cow_ro_iterator points to transient storage of this immutable iterator. In case write_back() won't be called and this iterator destructs, the returned immutable iterator is invalidated.

See also
size()
end()

Definition at line 241 of file cow_iterator.hpp.

◆ insert() [1/3]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr void jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::insert ( const value_type x)
inlineconstexpr

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

size will be increased by one.

This iterator is set to the inserted element.

Definition at line 512 of file cow_iterator.hpp.

◆ insert() [2/3]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
template<class InputIt >
constexpr void jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::insert ( InputIt  first,
InputIt  last 
)
inlineconstexpr

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

This iterator is set to the first element inserted, or pos if 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 559 of file cow_iterator.hpp.

◆ insert() [3/3]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr void jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::insert ( value_type &&  x)
inlineconstexpr

Inserts the element before the current position (std::move operation) and moves all elements from there to the right beforehand.

size will be increased by one.

This iterator is set to the inserted element.

Definition at line 526 of file cow_iterator.hpp.

◆ is_begin()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr bool jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::is_begin ( ) const
inlineconstexprnoexcept

Returns true, if this iterator points to begin().

Definition at line 321 of file cow_iterator.hpp.

◆ is_end()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr bool jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::is_end ( ) const
inlineconstexprnoexcept

Returns true, if this iterator points to end().

Definition at line 305 of file cow_iterator.hpp.

Here is the caller graph for this function:

◆ operator!=()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr bool jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator!= ( const cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container > &  rhs) const
inlineconstexprnoexcept

Definition at line 354 of file cow_iterator.hpp.

Here is the call graph for this function:

◆ operator*() [1/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr const reference jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator* ( ) const
inlineconstexprnoexcept

Dereferencing iterator to value_type reference.

Returns
immutable reference to value_type

Definition at line 377 of file cow_iterator.hpp.

◆ operator*() [2/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr reference jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator* ( )
inlineconstexprnoexcept

Dereferencing iterator to value_type reference.

Returns
mutable reference to value_type

Definition at line 393 of file cow_iterator.hpp.

◆ operator+()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr cow_rw_iterator jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator+ ( difference_type  rhs) const
inlineconstexprnoexcept

Binary 'iterator + element_count'; Try to avoid: Low performance due to returning copy-ctor.

Definition at line 443 of file cow_iterator.hpp.

◆ operator++() [1/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr cow_rw_iterator& jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator++ ( )
inlineconstexprnoexcept

Pre-increment; Well performing, return *this.


Definition at line 404 of file cow_iterator.hpp.

◆ operator++() [2/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr cow_rw_iterator jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator++ ( int  )
inlineconstexprnoexcept

Post-increment; Try to avoid: Low performance due to returning copy-ctor.

Definition at line 410 of file cow_iterator.hpp.

◆ operator+=()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr cow_rw_iterator& jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator+= ( difference_type  i)
inlineconstexprnoexcept

Addition-assignment of 'element_count'; Well performing, return *this.


Definition at line 439 of file cow_iterator.hpp.

◆ operator-() [1/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr difference_type jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator- ( const cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container > &  rhs) const
inlineconstexprnoexcept

Binary 'iterator - iterator -> element_count'; Well performing, return element_count of type difference_type.

Definition at line 457 of file cow_iterator.hpp.

◆ operator-() [2/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr cow_rw_iterator jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator- ( difference_type  rhs) const
inlineconstexprnoexcept

Binary 'iterator - element_count'; Try to avoid: Low performance due to returning copy-ctor.

Definition at line 451 of file cow_iterator.hpp.

◆ operator--() [1/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr cow_rw_iterator& jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator-- ( )
inlineconstexprnoexcept

Pre-decrement; Well performing, return *this.


Definition at line 416 of file cow_iterator.hpp.

◆ operator--() [2/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr cow_rw_iterator jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator-- ( int  )
inlineconstexprnoexcept

Post-decrement; Try to avoid: Low performance due to returning copy-ctor.

Definition at line 422 of file cow_iterator.hpp.

◆ operator-=()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr cow_rw_iterator& jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator-= ( difference_type  i)
inlineconstexprnoexcept

Subtraction-assignment of 'element_count'; Well performing, return *this.


Definition at line 447 of file cow_iterator.hpp.

◆ operator->() [1/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr const pointer jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator-> ( ) const
inlineconstexprnoexcept

Pointer to member access.

Returns
immutable pointer to value_type

Definition at line 385 of file cow_iterator.hpp.

◆ operator->() [2/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr pointer jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator-> ( )
inlineconstexprnoexcept

Pointer to member access.

Returns
mutable pointer to value_type

Definition at line 399 of file cow_iterator.hpp.

◆ operator<()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr bool jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator< ( const cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container > &  rhs) const
inlineconstexprnoexcept

Definition at line 362 of file cow_iterator.hpp.

Here is the call graph for this function:

◆ operator<=()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr bool jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator<= ( const cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container > &  rhs) const
inlineconstexprnoexcept

Definition at line 359 of file cow_iterator.hpp.

Here is the call graph for this function:

◆ operator=() [1/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr cow_rw_iterator& jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator= ( const cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container > &  o)
inlineconstexprnoexcept

Assigns content of other mutable iterator to this one, if they are not identical.

C++ named requirements: LegacyIterator: CopyAssignable

Parameters
othe new identity value to be copied into this iterator
Returns
reference to this

Definition at line 179 of file cow_iterator.hpp.

◆ operator=() [2/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr cow_rw_iterator& jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator= ( cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container > &&  o)
inlineconstexprnoexcept

Assigns identity of given mutable iterator, if they are not identical.

C++ named requirements: LegacyIterator: MoveAssignable

Parameters
othe new identity to be taken
Returns
reference to this

Definition at line 209 of file cow_iterator.hpp.

◆ operator==()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr bool jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator== ( const cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container > &  rhs) const
inlineconstexprnoexcept

Definition at line 351 of file cow_iterator.hpp.

Here is the call graph for this function:

◆ operator>()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr bool jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator> ( const cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container > &  rhs) const
inlineconstexprnoexcept

Definition at line 368 of file cow_iterator.hpp.

Here is the call graph for this function:

◆ operator>=()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr bool jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator>= ( const cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container > &  rhs) const
inlineconstexprnoexcept

Definition at line 365 of file cow_iterator.hpp.

Here is the call graph for this function:

◆ operator[]() [1/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr const reference jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator[] ( difference_type  i) const
inlineconstexprnoexcept

Subscript of 'element_index', returning immutable Value_type reference.

Definition at line 428 of file cow_iterator.hpp.

◆ operator[]() [2/2]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr reference jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::operator[] ( difference_type  i)
inlineconstexprnoexcept

Subscript of 'element_index', returning mutable Value_type reference.

Definition at line 434 of file cow_iterator.hpp.

◆ pop_back()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr void jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::pop_back ( )
inlineconstexprnoexcept

Removes the last element and sets this iterator to end()

Definition at line 477 of file cow_iterator.hpp.

◆ push_back() [1/3]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr void jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::push_back ( const value_type x)
inlineconstexpr

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

This iterator is set to the end.

Parameters
xthe value to be added at the tail.

Definition at line 570 of file cow_iterator.hpp.

◆ push_back() [2/3]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
template<class InputIt >
constexpr void jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::push_back ( InputIt  first,
InputIt  last 
)
inlineconstexpr

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

This iterator is set to the end.

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 617 of file cow_iterator.hpp.

◆ push_back() [3/3]

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr void jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::push_back ( value_type &&  x)
inlineconstexpr

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

This iterator is set to the end.

Parameters
xthe value to be added at the tail.

Definition at line 582 of file cow_iterator.hpp.

◆ size()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr size_type jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::size ( ) const
inlineconstexprnoexcept

Return the size of the underlying value_type store.

This is an addition API entry, allowing data-race free arithmetic on this iterator's data snapshot from a potentially mutated CoW.

See also
begin()
end()

Definition at line 288 of file cow_iterator.hpp.

◆ storage()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr storage_t& jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::storage ( ) const
inlineconstexprnoexcept

Returns this instances' underlying shared storage by reference.

Definition at line 293 of file cow_iterator.hpp.

◆ swap()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
void jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::swap ( cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container > &  o)
inlinenoexcept

C++ named requirements: LegacyIterator: Swappable.

Definition at line 223 of file cow_iterator.hpp.

◆ to_begin()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr cow_rw_iterator& jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::to_begin ( )
inlineconstexprnoexcept

This iterator is set to the first element, begin().

Returns *this;

Definition at line 326 of file cow_iterator.hpp.

Here is the call graph for this function:

◆ to_end()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr cow_rw_iterator& jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::to_end ( )
inlineconstexprnoexcept

This iterator is set to the last element, end().

Returns *this;

Definition at line 310 of file cow_iterator.hpp.

Here is the call graph for this function:

◆ toString()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
constexpr_cxx20 std::string jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::toString ( ) const
inlinenoexcept

Definition at line 460 of file cow_iterator.hpp.

Here is the caller graph for this function:

◆ write_back()

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
void jau::cow_rw_iterator< Storage_type, Storage_ref_type, CoW_container >::write_back ( )
inlinenoexcept

Replace the parent's current store with this iterators' instance, unlock the CoW parents' write lock and discard all storage references.

After calling write_back(), this iterator is invalidated and no more operational.

It is the user's responsibility to issue call this method to update the CoW parents' storage.

It is not feasible nor effective to automatically earmark a dirty state on mutable operations.
This is due to the ambiguous semantics of like operator*().
Also usage of multiple iterators to one CoW instance during a mutable operation complicates such an automated task, especially as we wish to only realize one storage replacement at the end.
Lastly, the user probably wants to issue the CoW storage sync in a programmatic deterministic fashion at the end.

See also
jau::cow_darray::set_store()

Definition at line 153 of file cow_iterator.hpp.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ cow_darray

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
template<typename , typename , typename , bool , bool , bool >
friend class cow_darray
friend

Definition at line 86 of file cow_iterator.hpp.

◆ cow_vector

template<typename Storage_type , typename Storage_ref_type , typename CoW_container >
template<typename , typename >
friend class cow_vector
friend

Definition at line 87 of file cow_iterator.hpp.


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