CUSP
Loading...
Searching...
No Matches
cusp::join_iterator< Tuple > Class Template Reference

#include <join_iterator.h>

Public Types

typedef TransformIterator iterator
 The type of the join_iterator.
 

Public Methods

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

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;
}
1D array of elements that may reside in "host" or "device" memory space
The array1d class is a 1D vector container that may contain elements stored in "host" or "device" mem...
Definition array1d.h:99
Specialized array1d_view wrapping thrust::constant_iterator.
Definition array1d.h:616
Specialized array1d_view wrapping thrust::counting_iterator.
Definition array1d.h:566
RandomAccessIterator for access to array entries from two concatenated iterators.
An iterator which concatenates two separate iterators.

Definition at line 144 of file join_iterator.h.

Member Typedef Documentation

◆ iterator

template<typename Tuple >
typedef TransformIterator cusp::join_iterator< Tuple >::iterator

The type of the join_iterator.

Definition at line 188 of file join_iterator.h.

Constructor & Destructor Documentation

◆ join_iterator()

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

This constructor builds a join_iterator from a tuple of sizes and a tuple of iterators.

Parameters
t1Tuple of cumulative sizes for each range.
t2Tuple of iterators for each range.

Definition at line 194 of file join_iterator.h.

Member Function Documentation

◆ begin()

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.

◆ end()

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.

◆ operator[]()

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.