VTK  9.4.20250309
vtkTypedDataArrayIterator.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3
21#ifndef vtkTypedDataArrayIterator_h
22#define vtkTypedDataArrayIterator_h
23
24#include <iterator> // For iterator traits
25
26#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_5_0
27#include "vtkTypedDataArray.h" // For vtkTypedDataArray
28
29VTK_ABI_NAMESPACE_BEGIN
30template <class Scalar>
32 "This iterator is deprecated because vtkTypedDataArray is deprecated.") vtkTypedDataArrayIterator
33{
34public:
35 typedef std::random_access_iterator_tag iterator_category;
36 typedef Scalar value_type;
37 typedef std::ptrdiff_t difference_type;
38 typedef Scalar& reference;
39 typedef Scalar* pointer;
40
42 : Data(nullptr)
43 , Index(0)
44 {
45 }
46
48 : Data(arr)
49 , Index(index)
50 {
51 }
52
54 : Data(o.Data)
55 , Index(o.Index)
56 {
57 }
58
60 {
61 std::swap(this->Data, o.Data);
62 std::swap(this->Index, o.Index);
63 return *this;
64 }
65
67 {
68 return this->Data == o.Data && this->Index == o.Index;
69 }
70
72 {
73 return this->Data == o.Data && this->Index != o.Index;
74 }
75
77 {
78 return this->Data == o.Data && this->Index > o.Index;
79 }
80
82 {
83 return this->Data == o.Data && this->Index >= o.Index;
84 }
85
87 {
88 return this->Data == o.Data && this->Index < o.Index;
89 }
90
92 {
93 return this->Data == o.Data && this->Index <= o.Index;
94 }
95
96 Scalar& operator*() { return this->Data->GetValueReference(this->Index); }
97
98 Scalar* operator->() const { return &this->Data->GetValueReference(this->Index); }
99
100 Scalar& operator[](const difference_type& n)
101 {
102 return this->Data->GetValueReference(this->Index + n);
103 }
104
106 {
107 ++this->Index;
108 return *this;
109 }
110
112 {
113 --this->Index;
114 return *this;
115 }
116
118 {
119 return vtkTypedDataArrayIterator(this->Data, this->Index++);
120 }
121
123 {
124 return vtkTypedDataArrayIterator(this->Data, this->Index--);
125 }
126
128 {
129 return vtkTypedDataArrayIterator(this->Data, this->Index + n);
130 }
131
133 {
134 return vtkTypedDataArrayIterator(this->Data, this->Index - n);
135 }
136
138 {
139 return this->Index - other.Index;
140 }
141
143 {
144 this->Index += n;
145 return *this;
146 }
147
149 {
150 this->Index -= n;
151 return *this;
152 }
153
154private:
156 vtkIdType Index;
157};
158
159VTK_ABI_NAMESPACE_END
160#endif // vtkTypedDataArrayIterator_h
161
162// VTK-HeaderTest-Exclude: vtkTypedDataArrayIterator.h
STL-style random access iterator for vtkTypedDataArrays.
bool operator>=(const vtkTypedDataArrayIterator< Scalar > &o) const
vtkTypedDataArrayIterator & operator--()
vtkTypedDataArrayIterator & operator+=(const difference_type &n)
vtkTypedDataArrayIterator & operator-=(const difference_type &n)
vtkTypedDataArrayIterator operator++(int)
vtkTypedDataArrayIterator(vtkTypedDataArray< Scalar > *arr, const vtkIdType index=0)
vtkTypedDataArrayIterator operator+(const difference_type &n) const
vtkTypedDataArrayIterator operator--(int)
bool operator!=(const vtkTypedDataArrayIterator< Scalar > &o) const
Scalar & operator[](const difference_type &n)
vtkTypedDataArrayIterator(const vtkTypedDataArrayIterator &o)
bool operator==(const vtkTypedDataArrayIterator< Scalar > &o) const
bool operator<=(const vtkTypedDataArrayIterator< Scalar > &o) const
vtkTypedDataArrayIterator operator-(const difference_type &n) const
bool operator<(const vtkTypedDataArrayIterator< Scalar > &o) const
difference_type operator-(const vtkTypedDataArrayIterator &other) const
bool operator>(const vtkTypedDataArrayIterator< Scalar > &o) const
vtkTypedDataArrayIterator & operator++()
vtkTypedDataArrayIterator & operator=(vtkTypedDataArrayIterator< Scalar > o)
std::random_access_iterator_tag iterator_category
Extend vtkDataArray with abstract type-specific API.
#define VTK_DEPRECATED_IN_9_5_0(reason)
int vtkIdType
Definition vtkType.h:332