Enables a subset of a vector to be easily accessed or reversed without copying memory. More...
#include <VectorSlice.h>
Enables a subset of a vector to be easily accessed or reversed without copying memory.
Given a vector v, this class provides a way for defining slices of the vector of the form v[startInd:endInd:skip] (in python notation).
This class is designed for use with the std::vector and Eigen::VectorXd classes, but can work with any type that exposes the [] operator and has a size() function, which includes other VectorViews.
IMPORTANT: This class does not copy data, so segfaults could occur if the underlying vector goes out of scope before the view is destructed.
Definition at line 24 of file VectorSlice.h.
| Public Member Functions | |
| VectorSlice (VectorSlice< VecType, ScalarType > const &vec) | |
| VectorSlice< VecType, ScalarType > & | operator= (VectorSlice< VecType, ScalarType > const &vec) | 
| VectorSlice (VecType &dataIn, int startIndIn, int endIndIn, int skipIn=1) | |
| ScalarType & | operator() (int i) | 
| ScalarType | operator() (int i) const | 
| ScalarType & | operator[] (int i) | 
| ScalarType | operator[] (int i) const | 
| unsigned int | size () const | 
| void | CheckBounds (int i) const | 
| Public Attributes | |
| VecType & | data | 
| int | startInd | 
| int | endInd | 
| int | skip | 
| 
 | inline | 
Definition at line 28 of file VectorSlice.h.
| 
 | inline | 
Construct the view with a reference to vector of doubles. Note that endInd-startInd should have the same size as skip. Thus, reversing the order of std::vector would be accomplished with
Note that the second argument, endInd, is negative because the end index is not inclusive. Thus, endInd must be -1 to capture v[0].
| [in] | dataIn | The base vector that we want to slice. | 
| [in] | startIndIn | non-negative integer specifying the starting index in the data vector | 
| [in] | endIndIn | non-negative integer specifying the ending index in the data vector. Numpy indexing rules are followed, so this index is not-inclusive. @parm[in] skip. The number of | 
Definition at line 53 of file VectorSlice.h.
References muq::Utilities::VectorSlice< VecType, ScalarType >::endInd, muq::Utilities::VectorSlice< VecType, ScalarType >::skip, and muq::Utilities::VectorSlice< VecType, ScalarType >::startInd.
| 
 | inline | 
Definition at line 97 of file VectorSlice.h.
References muq::Utilities::VectorSlice< VecType, ScalarType >::endInd, muq::Utilities::VectorSlice< VecType, ScalarType >::skip, and muq::Utilities::VectorSlice< VecType, ScalarType >::startInd.
Referenced by muq::Utilities::VectorSlice< VecType, ScalarType >::operator()().
| 
 | inline | 
Definition at line 71 of file VectorSlice.h.
References muq::Utilities::VectorSlice< VecType, ScalarType >::CheckBounds(), muq::Utilities::VectorSlice< VecType, ScalarType >::data, muq::Utilities::VectorSlice< VecType, ScalarType >::skip, and muq::Utilities::VectorSlice< VecType, ScalarType >::startInd.
| 
 | inline | 
Definition at line 76 of file VectorSlice.h.
References muq::Utilities::VectorSlice< VecType, ScalarType >::CheckBounds(), muq::Utilities::VectorSlice< VecType, ScalarType >::data, muq::Utilities::VectorSlice< VecType, ScalarType >::skip, and muq::Utilities::VectorSlice< VecType, ScalarType >::startInd.
| 
 | inline | 
| 
 | inline | 
Definition at line 81 of file VectorSlice.h.
References muq::Utilities::VectorSlice< VecType, ScalarType >::data, muq::Utilities::VectorSlice< VecType, ScalarType >::skip, and muq::Utilities::VectorSlice< VecType, ScalarType >::startInd.
| 
 | inline | 
Definition at line 85 of file VectorSlice.h.
References muq::Utilities::VectorSlice< VecType, ScalarType >::data, muq::Utilities::VectorSlice< VecType, ScalarType >::skip, and muq::Utilities::VectorSlice< VecType, ScalarType >::startInd.
| 
 | inline | 
Definition at line 89 of file VectorSlice.h.
References muq::Utilities::VectorSlice< VecType, ScalarType >::endInd, muq::Utilities::VectorSlice< VecType, ScalarType >::skip, and muq::Utilities::VectorSlice< VecType, ScalarType >::startInd.
| VecType& muq::Utilities::VectorSlice< VecType, ScalarType >::data | 
| int muq::Utilities::VectorSlice< VecType, ScalarType >::endInd | 
Definition at line 95 of file VectorSlice.h.
Referenced by muq::Utilities::VectorSlice< VecType, ScalarType >::CheckBounds(), muq::Utilities::VectorSlice< VecType, ScalarType >::operator=(), muq::Utilities::VectorSlice< VecType, ScalarType >::size(), and muq::Utilities::VectorSlice< VecType, ScalarType >::VectorSlice().
| int muq::Utilities::VectorSlice< VecType, ScalarType >::skip | 
Definition at line 95 of file VectorSlice.h.
Referenced by muq::Utilities::VectorSlice< VecType, ScalarType >::CheckBounds(), muq::Utilities::GetSlice(), muq::Utilities::VectorSlice< VecType, ScalarType >::operator()(), muq::Utilities::VectorSlice< VecType, ScalarType >::operator=(), muq::Utilities::VectorSlice< VecType, ScalarType >::operator[](), muq::Utilities::VectorSlice< VecType, ScalarType >::size(), and muq::Utilities::VectorSlice< VecType, ScalarType >::VectorSlice().
| int muq::Utilities::VectorSlice< VecType, ScalarType >::startInd | 
Definition at line 95 of file VectorSlice.h.
Referenced by muq::Utilities::VectorSlice< VecType, ScalarType >::CheckBounds(), muq::Utilities::GetSlice(), muq::Utilities::VectorSlice< VecType, ScalarType >::operator()(), muq::Utilities::VectorSlice< VecType, ScalarType >::operator=(), muq::Utilities::VectorSlice< VecType, ScalarType >::operator[](), muq::Utilities::VectorSlice< VecType, ScalarType >::size(), and muq::Utilities::VectorSlice< VecType, ScalarType >::VectorSlice().