vecmem 1.14.0
Loading...
Searching...
No Matches
jagged_device_vector_iterator.ipp
1/*
2 * VecMem project, part of the ACTS project (R&D line)
3 *
4 * (c) 2021-2023 CERN for the benefit of the ACTS project
5 *
6 * Mozilla Public License Version 2.0
7 */
8#pragma once
9
10namespace vecmem {
11namespace details {
12
13template <typename TYPE>
15 const data_pointer data)
16 : m_vec(*data) {}
17
18template <typename TYPE>
19VECMEM_HOST_AND_DEVICE auto
24
25template <typename TYPE>
26VECMEM_HOST_AND_DEVICE auto
32
33template <typename TYPE>
34VECMEM_HOST_AND_DEVICE
37
38template <typename TYPE>
39VECMEM_HOST_AND_DEVICE
43
44template <typename TYPE>
45template <typename OTHERTYPE,
46 std::enable_if_t<details::is_same_nc<TYPE, OTHERTYPE>::value, bool> >
47VECMEM_HOST_AND_DEVICE
50 // Just like for vecmem::data::vector_view, this looks more scary than it
51 // is. We convert from a non-const type to a constant one here.
52 : m_ptr{reinterpret_cast<data_pointer>(data)} {}
53
54template <typename TYPE>
55VECMEM_HOST_AND_DEVICE
59
60template <typename TYPE>
61template <typename T>
62VECMEM_HOST_AND_DEVICE
66
67template <typename TYPE>
68VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator<TYPE>&
71
72 // Check if anything needs to be done.
73 if (this == &rhs) {
74 return *this;
75 }
76
77 // Perform the copy.
78 m_ptr = rhs.m_ptr;
79
80 // Return this object.
81 return *this;
82}
83
84template <typename TYPE>
86 const -> reference {
87
88 return reference{*m_ptr};
89}
90
91template <typename TYPE>
92VECMEM_HOST_AND_DEVICE auto
97
98template <typename TYPE>
100 difference_type n) const -> reference {
101
102 return reference{*(*this + n)};
103}
104
105template <typename TYPE>
106VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator<TYPE>&
108
109 ++m_ptr;
110 return *this;
111}
112
113template <typename TYPE>
114VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator<TYPE>
116
118 ++m_ptr;
119 return tmp;
120}
121
122template <typename TYPE>
123VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator<TYPE>&
125
126 --m_ptr;
127 return *this;
128}
129
130template <typename TYPE>
131VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator<TYPE>
133
135 --m_ptr;
136 return tmp;
137}
138
139template <typename TYPE>
140VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator<TYPE>
145
146template <typename TYPE>
147VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator<TYPE>&
149
150 m_ptr += n;
151 return *this;
152}
153
154template <typename TYPE>
155VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator<TYPE>
160
161template <typename TYPE>
162VECMEM_HOST_AND_DEVICE jagged_device_vector_iterator<TYPE>&
164
165 m_ptr -= n;
166 return *this;
167}
168
169template <typename TYPE>
172
173 return (m_ptr == other.m_ptr);
174}
175
176template <typename TYPE>
179
180 return !(*this == other);
181}
182
183} // namespace details
184} // namespace vecmem
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 pointer(const data_pointer data)
Constructor from a data pointer.
Definition jagged_device_vector_iterator.ipp:14
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
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