Embedded Multicore Building Blocks V1.0.0
Public Member Functions | List of all members
embb::algorithms::ZipIterator< IteratorA, IteratorB > Class Template Reference

Zip container for two iterators. More...

#include <zip_iterator.h>

Public Types

Iterator Typedefs

Necessary typedefs for iterators (std compatibility).

typedef std::random_access_iterator_tag iterator_category
 
typedef std::iterator_traits< IteratorA >::difference_type difference_type
 
typedef std::iterator_traits< IteratorA >::reference RefA
 
typedef std::iterator_traits< IteratorB >::reference RefB
 
typedef std::iterator_traits< IteratorA >::value_type ValueA
 
typedef std::iterator_traits< IteratorB >::value_type ValueB
 
typedef ZipPair< ValueA, ValueB > value_type
 
typedef ZipPair< RefA, RefB > reference
 
typedef ZipPair< RefA, RefB > pointer
 

Public Member Functions

 ZipIterator (IteratorA iter_a, IteratorB iter_b)
 Constructs a zip iterator from two iterators of any type. More...
 
bool operator== (const ZipIterator &other) const
 Compares two zip iterators for equality. More...
 
bool operator!= (const ZipIterator &other) const
 Compares two zip iterators for inequality. More...
 
void operator++ ()
 Applies prefix increment on both iterators. More...
 
void operator-- ()
 Applies prefix decrement on both iterators. More...
 
ZipIterator< IteratorA, IteratorB > operator+ (difference_type distance) const
 Returns an instance of a zip iterator where both iterators have been advanced by the specified distance. More...
 
ZipIterator< IteratorA, IteratorB > operator- (difference_type distance) const
 Returns an instance of a zip iterator where both iterators have been regressed by the specified distance. More...
 
ZipIterator< IteratorA, IteratorB > & operator+= (difference_type distance)
 Advances both iterators by the specified distance. More...
 
ZipIterator< IteratorA, IteratorB > & operator-= (difference_type distance)
 Regresses both iterators by the specified distance. More...
 
difference_type operator- (const ZipIterator< IteratorA, IteratorB > &other) const
 Computes the distance between two zip iterators. More...
 
reference operator* () const
 Dereferences the zip iterator. More...
 

Detailed Description

template<typename IteratorA, typename IteratorB>
class embb::algorithms::ZipIterator< IteratorA, IteratorB >

Zip container for two iterators.

This container allows zipping two iterators together, thus enabling them to be used in situations where only one iterator can be used. Any operation applied to the zip iterator will subsequently be applied to the contained iterators. Dereferencing the iterator will return a ZipPair containing the values referenced by the iterators.

Concurrency
Not thread-safe
Note
It is required that the two iterators have the same difference_type or that at least the first iterator's difference_type can be implicitly converted to the second iterator's difference_type. Moreover, when calculating the distance between two ZipIterators, the distances between both pairs of iterators are equal.
See also
ZipPair
Template Parameters
IteratorAFirst iterator
IteratorBSecond iterator

Constructor & Destructor Documentation

template<typename IteratorA, typename IteratorB>
embb::algorithms::ZipIterator< IteratorA, IteratorB >::ZipIterator ( IteratorA  iter_a,
IteratorB  iter_b 
)

Constructs a zip iterator from two iterators of any type.

Parameters
[in]iter_aFirst iterator
[in]iter_bSecond iterator

Member Function Documentation

template<typename IteratorA, typename IteratorB>
bool embb::algorithms::ZipIterator< IteratorA, IteratorB >::operator== ( const ZipIterator< IteratorA, IteratorB > &  other) const

Compares two zip iterators for equality.

Returns
true if zip iterators are equal, otherwise false
Parameters
[in]otherReference to right-hand side of equality operator
template<typename IteratorA, typename IteratorB>
bool embb::algorithms::ZipIterator< IteratorA, IteratorB >::operator!= ( const ZipIterator< IteratorA, IteratorB > &  other) const

Compares two zip iterators for inequality.

Returns
true if any iterator doesn't equal the other, otherwise false
Parameters
[in]otherReference to right-hand side of inequality operator
template<typename IteratorA, typename IteratorB>
void embb::algorithms::ZipIterator< IteratorA, IteratorB >::operator++ ( )

Applies prefix increment on both iterators.

template<typename IteratorA, typename IteratorB>
void embb::algorithms::ZipIterator< IteratorA, IteratorB >::operator-- ( )

Applies prefix decrement on both iterators.

template<typename IteratorA, typename IteratorB>
ZipIterator<IteratorA, IteratorB> embb::algorithms::ZipIterator< IteratorA, IteratorB >::operator+ ( difference_type  distance) const

Returns an instance of a zip iterator where both iterators have been advanced by the specified distance.

Returns
New zip iterator containing the advanced iterators
Parameters
[in]distanceNumber of elements to advance the iterators
template<typename IteratorA, typename IteratorB>
ZipIterator<IteratorA, IteratorB> embb::algorithms::ZipIterator< IteratorA, IteratorB >::operator- ( difference_type  distance) const

Returns an instance of a zip iterator where both iterators have been regressed by the specified distance.

Returns
New zip iterator containing the regressed iterators
Parameters
[in]distanceNumber of elements to regress the iterators
template<typename IteratorA, typename IteratorB>
ZipIterator<IteratorA, IteratorB>& embb::algorithms::ZipIterator< IteratorA, IteratorB >::operator+= ( difference_type  distance)

Advances both iterators by the specified distance.

Returns
Reference to *this
Parameters
[in]distanceNumber of elements to advance the iterators
template<typename IteratorA, typename IteratorB>
ZipIterator<IteratorA, IteratorB>& embb::algorithms::ZipIterator< IteratorA, IteratorB >::operator-= ( difference_type  distance)

Regresses both iterators by the specified distance.

Returns
Reference to *this
Parameters
[in]distanceNumber of elements to regress the iterators
template<typename IteratorA, typename IteratorB>
difference_type embb::algorithms::ZipIterator< IteratorA, IteratorB >::operator- ( const ZipIterator< IteratorA, IteratorB > &  other) const

Computes the distance between two zip iterators.

It is assumed that both iterator pairs have the same distance.

Returns
The distance between the zip iterators
Parameters
[in]otherReference to right-hand side of subtraction operator
template<typename IteratorA, typename IteratorB>
reference embb::algorithms::ZipIterator< IteratorA, IteratorB >::operator* ( ) const

Dereferences the zip iterator.

Returns
ZipPair containing the dereferenced values.