1 #ifndef SimTK_SIMMATRIX_VECTORITERATOR_H_ 2 #define SimTK_SIMMATRIX_VECTORITERATOR_H_ 51 template <
class ELT,
class VECTOR_CLASS>
52 class VectorIterator {
63 : vectorp(&vector), index(index) {}
77 assert (index >= 0 && index < vectorp->size());
78 return (*vectorp)[(int)index];
81 assert (i >= 0 && i < vectorp->size());
82 return (*vectorp)[(int)i];
85 assert (index < vectorp->size());
90 assert (index < vectorp->size());
107 assert (0 <= index+n && index+n <= vectorp->size());
112 assert (0 <= index-n && index-n <= vectorp->size());
117 return (index < iter.index);
120 return (index > iter.index);
123 return (index <= iter.index);
126 return (index >= iter.index);
129 return (index - iter.index);
138 return (index == iter.index);
141 return (index != iter.index);
144 VECTOR_CLASS* vectorp;
150 #endif // SimTK_SIMMATRIX_VECTORITERATOR_H_ bool operator!=(const VectorIterator &iter) const
Definition: VectorIterator.h:140
bool operator>=(const VectorIterator &iter) const
Definition: VectorIterator.h:125
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
VectorIterator operator-(ptrdiff_t n) const
Definition: VectorIterator.h:131
std::random_access_iterator_tag iterator_category
Definition: VectorIterator.h:58
bool operator>(const VectorIterator &iter) const
Definition: VectorIterator.h:119
bool operator<=(const VectorIterator &iter) const
Definition: VectorIterator.h:122
VectorIterator(VECTOR_CLASS &vector, ptrdiff_t index)
Create an iterator for the supplied vector and set it to refer to the element at index.
Definition: VectorIterator.h:62
VectorIterator & operator+=(ptrdiff_t n)
Definition: VectorIterator.h:106
ptrdiff_t operator-(const VectorIterator &iter) const
Definition: VectorIterator.h:128
VectorIterator operator+(ptrdiff_t n) const
Definition: VectorIterator.h:134
VectorIterator()=delete
No default constructor.
This is an iterator for iterating over the elements of a Vector_ or Vec object.
Definition: BigMatrix.h:176
VectorIterator operator++(int)
Definition: VectorIterator.h:89
bool operator<(const VectorIterator &iter) const
Definition: VectorIterator.h:116
VectorIterator operator--(int)
Definition: VectorIterator.h:100
VectorIterator & operator=(const VectorIterator &source)=default
Copy assignment makes this iterator refer to the same element of the same vector as the source iterat...
ELT & operator[](ptrdiff_t i)
Definition: VectorIterator.h:80
VectorIterator & operator--()
Definition: VectorIterator.h:95
ELT & operator*()
Definition: VectorIterator.h:76
VectorIterator & operator-=(ptrdiff_t n)
Definition: VectorIterator.h:111
ELT value_type
Definition: VectorIterator.h:54
VectorIterator & operator++()
Definition: VectorIterator.h:84
ptrdiff_t difference_type
Definition: VectorIterator.h:55
ELT & reference
Definition: VectorIterator.h:56
ELT * pointer
Definition: VectorIterator.h:57
bool operator==(const VectorIterator &iter) const
Definition: VectorIterator.h:137