10 #ifndef vtk_m_exec_cuda_internal_IteratorFromArrayPortal_h
11 #define vtk_m_exec_cuda_internal_IteratorFromArrayPortal_h
21 #include <thrust/functional.h>
22 #include <thrust/iterator/iterator_facade.h>
23 #include <thrust/system/cuda/execution_policy.h>
35 template <
class ArrayPortalType>
36 class IteratorFromArrayPortal
37 :
public ::thrust::iterator_facade<IteratorFromArrayPortal<ArrayPortalType>,
38 typename ArrayPortalType::ValueType,
39 ::thrust::system::cuda::tag,
40 ::thrust::random_access_traversal_tag,
41 vtkm::internal::ArrayPortalValueReference<ArrayPortalType>,
46 IteratorFromArrayPortal()
53 explicit IteratorFromArrayPortal(
const ArrayPortalType& portal,
vtkm::Id index = 0)
60 vtkm::internal::ArrayPortalValueReference<ArrayPortalType> operator[](
61 std::ptrdiff_t idx)
const
63 return vtkm::internal::ArrayPortalValueReference<ArrayPortalType>(
68 ArrayPortalType Portal;
72 friend class ::thrust::iterator_core_access;
75 vtkm::internal::ArrayPortalValueReference<ArrayPortalType> dereference()
const
77 return vtkm::internal::ArrayPortalValueReference<ArrayPortalType>(this->Portal, this->Index);
81 bool equal(
const IteratorFromArrayPortal<ArrayPortalType>& other)
const
87 return (this->Index == other.Index);
91 void increment() { this->Index++; }
94 void decrement() { this->Index--; }
97 void advance(std::ptrdiff_t delta) { this->Index +=
static_cast<vtkm::Id>(delta); }
100 std::ptrdiff_t distance_to(
const IteratorFromArrayPortal<ArrayPortalType>& other)
const
106 return static_cast<std::ptrdiff_t
>(other.Index - this->
Index);
127 template <
typename T>
128 struct is_non_const_reference;
130 template <
typename T>
131 struct is_non_const_reference<
vtkm::internal::ArrayPortalValueReference<T>>
132 : thrust::detail::true_type
138 #endif //vtk_m_exec_cuda_internal_IteratorFromArrayPortal_h