vecmem 1.14.0
Loading...
Searching...
No Matches
reverse_iterator.hpp
1/* VecMem project, part of the ACTS project (R&D line)
2 *
3 * (c) 2021 CERN for the benefit of the ACTS project
4 *
5 * Mozilla Public License Version 2.0
6 */
7#pragma once
8
9// Local include(s).
10#include "vecmem/utils/types.hpp"
11
12// System include(s).
13#include <iterator>
14
15namespace vecmem {
16namespace details {
17
24template <typename Iterator>
26
27public:
30
34 typedef typename std::iterator_traits<iterator_type>::value_type value_type;
36 typedef typename std::iterator_traits<iterator_type>::difference_type
39 typedef typename std::iterator_traits<iterator_type>::pointer pointer;
41 typedef typename std::iterator_traits<iterator_type>::reference reference;
42
44
46 VECMEM_HOST_AND_DEVICE
49 VECMEM_HOST_AND_DEVICE
51
53 VECMEM_HOST_AND_DEVICE
56 template <typename T>
57 VECMEM_HOST_AND_DEVICE reverse_iterator(const reverse_iterator<T>& parent);
58
60 VECMEM_HOST_AND_DEVICE
62
64 VECMEM_HOST_AND_DEVICE
65 iterator_type base() const;
66
69
71 VECMEM_HOST_AND_DEVICE
72 reference operator*() const;
74 VECMEM_HOST_AND_DEVICE
75 pointer operator->() const;
77 VECMEM_HOST_AND_DEVICE
79
81
84
86 VECMEM_HOST_AND_DEVICE
89 VECMEM_HOST_AND_DEVICE
91
93 VECMEM_HOST_AND_DEVICE
96 VECMEM_HOST_AND_DEVICE
98
100 VECMEM_HOST_AND_DEVICE
103 VECMEM_HOST_AND_DEVICE
105
107 VECMEM_HOST_AND_DEVICE
110 VECMEM_HOST_AND_DEVICE
112
114
115private:
117 template <typename T>
118 VECMEM_HOST_AND_DEVICE static T* to_pointer(T* ptr);
120 template <typename T>
121 VECMEM_HOST_AND_DEVICE static pointer to_pointer(T itr);
122
124 iterator_type m_current;
125
126}; // class reverse_iterator
127
129template <typename T1, typename T2>
130VECMEM_HOST_AND_DEVICE bool operator==(const reverse_iterator<T1>& itr1,
133template <typename T1, typename T2>
134VECMEM_HOST_AND_DEVICE bool operator!=(const reverse_iterator<T1>& itr1,
136
137} // namespace details
138} // namespace vecmem
139
140// Include the implementation.
141#include "vecmem/containers/impl/reverse_iterator.ipp"
Type mimicking std::reverse_iterator.
Definition reverse_iterator.hpp:25
VECMEM_HOST_AND_DEVICE reverse_iterator & operator--()
Increment the underlying iterator (with '–' as a prefix)
Definition reverse_iterator.ipp:100
std::iterator_traits< iterator_type >::pointer pointer
Pointer type to the underlying value.
Definition reverse_iterator.hpp:39
Iterator iterator_type
Type of the forward iterator, being wrapped.
Definition reverse_iterator.hpp:32
VECMEM_HOST_AND_DEVICE reverse_iterator & operator-=(difference_type n)
Increment the underlying iterator by a specific value.
Definition reverse_iterator.ipp:139
VECMEM_HOST_AND_DEVICE reverse_iterator & operator=(const reverse_iterator &rhs)
Copy assignment operator.
Definition reverse_iterator.ipp:37
VECMEM_HOST_AND_DEVICE pointer operator->() const
Use the iterator as a pointer.
Definition reverse_iterator.ipp:68
std::iterator_traits< iterator_type >::reference reference
Reference type to the underlying value.
Definition reverse_iterator.hpp:41
std::iterator_traits< iterator_type >::value_type value_type
Value type being iterated on.
Definition reverse_iterator.hpp:34
VECMEM_HOST_AND_DEVICE reverse_iterator & operator+=(difference_type n)
Decrement the underlying iterator by a specific value.
Definition reverse_iterator.ipp:124
VECMEM_HOST_AND_DEVICE reverse_iterator & operator++()
Decrement the underlying iterator (with '++' as a prefix)
Definition reverse_iterator.ipp:83
VECMEM_HOST_AND_DEVICE iterator_type base() const
Access the base/forward iterator.
Definition reverse_iterator.ipp:53
std::iterator_traits< iterator_type >::difference_type difference_type
(Pointer) Difference type
Definition reverse_iterator.hpp:37
VECMEM_HOST_AND_DEVICE reverse_iterator()
Default constructor.
Definition reverse_iterator.ipp:16
VECMEM_HOST_AND_DEVICE reverse_iterator operator-(difference_type n) const
Increment the underlying iterator by a specific value.
Definition reverse_iterator.ipp:132
VECMEM_HOST_AND_DEVICE reference operator[](difference_type n) const
Return the value at a specific offset.
Definition reverse_iterator.ipp:76
VECMEM_HOST_AND_DEVICE reference operator*() const
De-reference the iterator.
Definition reverse_iterator.ipp:60
VECMEM_HOST_AND_DEVICE reverse_iterator operator+(difference_type n) const
Decrement the underlying iterator by a specific value.
Definition reverse_iterator.ipp:117
VECMEM_HOST_AND_DEVICE bool operator==(const reverse_iterator< T1 > &itr1, const reverse_iterator< T2 > &itr2)
Comparison operator for reverse iterators.
Definition reverse_iterator.ipp:161
VECMEM_HOST_AND_DEVICE bool operator!=(const reverse_iterator< T1 > &itr1, const reverse_iterator< T2 > &itr2)
Comparison operator for reverse iterators.
Definition reverse_iterator.ipp:168
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