vecmem 1.14.0
Loading...
Searching...
No Matches
jagged_device_vector_iterator.hpp
1/*
2 * VecMem project, part of the ACTS project (R&D line)
3 *
4 * (c) 2021-2024 CERN for the benefit of the ACTS project
5 *
6 * Mozilla Public License Version 2.0
7 */
8#pragma once
9
10// Local include(s).
11#include "vecmem/containers/data/vector_view.hpp"
12#include "vecmem/containers/device_vector.hpp"
13#include "vecmem/utils/types.hpp"
14
15// System include(s).
16#include <cstddef>
17#include <iterator>
18#include <type_traits>
19
20namespace vecmem {
21namespace details {
22
33template <typename TYPE>
35
36public:
39
43 typedef std::add_pointer_t<std::add_const_t<data_type>> data_pointer;
44
46
49
53 typedef std::ptrdiff_t difference_type;
56
63 class pointer {
64
65 public:
72 VECMEM_HOST_AND_DEVICE
73 explicit pointer(const data_pointer data);
74
76 VECMEM_HOST_AND_DEVICE
79 VECMEM_HOST_AND_DEVICE
80 const value_type* operator->() const;
81
82 private:
84 value_type m_vec;
85
86 }; // class pointer
87
89
91 VECMEM_HOST_AND_DEVICE
94 VECMEM_HOST_AND_DEVICE
97 template <typename OTHERTYPE,
98 std::enable_if_t<details::is_same_nc<TYPE, OTHERTYPE>::value,
99 bool> = true>
100 VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator(
101 const data::vector_view<OTHERTYPE>* data);
103 VECMEM_HOST_AND_DEVICE
106 template <typename T>
107 VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator(
109
111 VECMEM_HOST_AND_DEVICE
114
117
119 VECMEM_HOST_AND_DEVICE
120 reference operator*() const;
122 VECMEM_HOST_AND_DEVICE
123 pointer operator->() const;
125 VECMEM_HOST_AND_DEVICE
127
129
132
134 VECMEM_HOST_AND_DEVICE
137 VECMEM_HOST_AND_DEVICE
139
141 VECMEM_HOST_AND_DEVICE
144 VECMEM_HOST_AND_DEVICE
146
148 VECMEM_HOST_AND_DEVICE
151 VECMEM_HOST_AND_DEVICE
153
155 VECMEM_HOST_AND_DEVICE
158 VECMEM_HOST_AND_DEVICE
160
162
165
167 VECMEM_HOST_AND_DEVICE
170 VECMEM_HOST_AND_DEVICE
172
174
175private:
177 data_pointer m_ptr;
178
179}; // class jagged_device_vector_iterator
180
181} // namespace details
182} // namespace vecmem
183
184namespace std {
185
191template <typename T>
192struct iterator_traits<vecmem::details::jagged_device_vector_iterator<T>> {
193 typedef
195 value_type;
197 T>::difference_type difference_type;
199 pointer;
200 typedef
202 reference;
203 typedef std::random_access_iterator_tag iterator_category;
204};
205
206} // namespace std
207
208// Include the implementation.
209#include "vecmem/containers/impl/jagged_device_vector_iterator.ipp"
Class holding data about a 1 dimensional vector/array.
Definition vector_view.hpp:38
Helper class for returning "pointer-like" objects from the iterator.
Definition jagged_device_vector_iterator.hpp:63
VECMEM_HOST_AND_DEVICE value_type * operator->()
Return a pointer to a device vector (non-const)
Definition jagged_device_vector_iterator.ipp:20
Custom iterator for vecmem::jagged_device_vector.
Definition jagged_device_vector_iterator.hpp:34
std::add_pointer_t< std::add_const_t< data_type > > data_pointer
Pointer to the data object.
Definition jagged_device_vector_iterator.hpp:43
VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator operator-(difference_type n) const
Increment the underlying iterator by a specific value.
Definition jagged_device_vector_iterator.ipp:156
VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator & operator=(const jagged_device_vector_iterator &rhs)
Copy assignment operator.
Definition jagged_device_vector_iterator.ipp:69
VECMEM_HOST_AND_DEVICE bool operator!=(const jagged_device_vector_iterator &other) const
Check for the inequality of two iterators.
Definition jagged_device_vector_iterator.ipp:177
VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator operator+(difference_type n) const
Decrement the underlying iterator by a specific value.
Definition jagged_device_vector_iterator.ipp:141
VECMEM_HOST_AND_DEVICE reference operator[](difference_type n) const
Return the value at a specific offset.
Definition jagged_device_vector_iterator.ipp:99
VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator()
Default constructor.
Definition jagged_device_vector_iterator.ipp:35
data::vector_view< TYPE > data_type
Type of the data object that we have an array of.
Definition jagged_device_vector_iterator.hpp:41
value_type reference
"Reference" type to the underlying (virtual) value
Definition jagged_device_vector_iterator.hpp:55
std::ptrdiff_t difference_type
(Pointer) Difference type
Definition jagged_device_vector_iterator.hpp:53
device_vector< TYPE > value_type
Value type being (virtually) iterated on.
Definition jagged_device_vector_iterator.hpp:51
VECMEM_HOST_AND_DEVICE reference operator*() const
De-reference the iterator.
Definition jagged_device_vector_iterator.ipp:85
VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator & operator+=(difference_type n)
Decrement the underlying iterator by a specific value.
Definition jagged_device_vector_iterator.ipp:148
VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator & operator--()
Increment the underlying iterator (with '–' as a prefix)
Definition jagged_device_vector_iterator.ipp:124
VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator & operator-=(difference_type n)
Increment the underlying iterator by a specific value.
Definition jagged_device_vector_iterator.ipp:163
VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator & operator++()
Decrement the underlying iterator (with '++' as a prefix)
Definition jagged_device_vector_iterator.ipp:107
VECMEM_HOST_AND_DEVICE bool operator==(const jagged_device_vector_iterator &other) const
Check for the equality of two iterators.
Definition jagged_device_vector_iterator.ipp:170
VECMEM_HOST_AND_DEVICE pointer operator->() const
Use the iterator as a pointer.
Definition jagged_device_vector_iterator.ipp:93
Main namespace for the vecmem classes/functions.
Definition atomic_ref.hpp:16
std::vector< T, vecmem::polymorphic_allocator< T > > vector
Alias type for vectors with our polymorphic allocator.
Definition vector.hpp:35