Fork me on GitHub
 All Classes Files Functions Variables Groups Pages
Public Types | Public Methods | List of all members
cusp::join_iterator< Tuple > Class Template Reference

Detailed description

template<typename Tuple>
class cusp::join_iterator< Tuple >

RandomAccessIterator for access to array entries from two concatenated iterators.

Template Parameters
Iterator1The iterator type used to encapsulate the first set of entries.
Iterator2The iterator type used to encapsulate the second set of entries.
Iterator3The iterator type used to order concatenated entries from two separate iterators.
Overview
join_iterator is an iterator which represents a pointer into a concatenated range of entries from two underlying arrays. This iterator is useful for creating a single range of permuted entries from two different iterators.
Example
The following code snippet demonstrates how to create a join_iterator whose value_type is int and whose values are gather from a counting_iterator and a constant_iterator.
#include <cusp/array1d.h>
#include <thrust/sequence.h>
#include <iostream>
int main(void)
{
typedef cusp::counting_array<int> CountingArray;
typedef cusp::constant_array<int> ConstantArray;
typedef typename CountingArray::iterator CountingIterator;
typedef typename ConstantArray::iterator ConstantIterator;
// a = [0, 1, 2, 3]
CountingArray a(4);
// b = [10, 10, 10, 10, 10]
ConstantArray b(5, 10);
cusp::array1d<int,cusp::device_memory> indices(a.size() + b.size());
// set indices to a sequence for simple in order access
thrust::sequence(indices.begin(), indices.end());
// iter = [0, 1, 2, 3, 10, 10, 10, 10, 10]
JoinIterator iter(a.begin(), a.end(), b.begin(), b.end(), indices.begin());
std::cout << iter[0] << std::endl; // returns 0
std::cout << iter[3] << std::endl; // returns 3
std::cout << iter[4] << std::endl; // returns 10
return 0;
}

Definition at line 141 of file join_iterator.h.

#include <join_iterator.h>

Public Types

typedef TransformIterator iterator
 

Public Methods

 join_iterator (const SizesTuple &t1, const Tuple &t2)
 This constructor builds a join_iterator from two iterators. More...
 
iterator begin (void) const
 This method returns an iterator pointing to the beginning of this joined sequence of permuted entries. More...
 
iterator end (void) const
 This method returns an iterator pointing to one element past the last of this joined sequence of permuted entries. More...
 
reference operator[] (size_type n) const
 Subscript access to the data contained in this iterator. More...
 

Constructor & Destructor Documentation

template<typename Tuple >
cusp::join_iterator< Tuple >::join_iterator ( const SizesTuple &  t1,
const Tuple &  t2 
)
inline

This constructor builds a join_iterator from two iterators.

Parameters
first_beginThe beginning of the first range.
first_endThe end of the first range.
second_beginThe beginning of the second range.
second_endThe end of the second range.
indices_beginThe permutation indices used to order entries from the two joined iterators.

Definition at line 194 of file join_iterator.h.

Member Function Documentation

template<typename Tuple >
iterator cusp::join_iterator< Tuple >::begin ( void  ) const
inline

This method returns an iterator pointing to the beginning of this joined sequence of permuted entries.

Returns
mStart

Definition at line 200 of file join_iterator.h.

template<typename Tuple >
iterator cusp::join_iterator< Tuple >::end ( void  ) const
inline

This method returns an iterator pointing to one element past the last of this joined sequence of permuted entries.

Returns
mEnd

Definition at line 209 of file join_iterator.h.

template<typename Tuple >
reference cusp::join_iterator< Tuple >::operator[] ( size_type  n) const
inline

Subscript access to the data contained in this iterator.

Parameters
nThe index of the element for which data should be accessed.
Returns
Read/write reference to data.

This operator allows for easy, array-style, data access. Note that data access with this operator is unchecked and out_of_range lookups are not defined.

Definition at line 222 of file join_iterator.h.