Reference documentation for deal.II version 9.1.0-pre
Public Member Functions | Private Attributes | Related Functions | List of all members
VectorSlice< VectorType > Class Template Reference

#include <deal.II/base/vector_slice.h>

Public Member Functions

 VectorSlice (VectorType &v)
 
 VectorSlice (VectorType &v, unsigned int start, unsigned int length)
 
 operator ArrayView< typename VectorType::value_type * > ()
 
 operator ArrayView< const typename VectorType::value_type * > () const
 
unsigned int size () const
 
VectorType::reference operator[] (unsigned int i)
 
VectorType::const_reference operator[] (unsigned int i) const
 
VectorType::iterator begin ()
 
VectorType::const_iterator begin () const
 
VectorType::iterator end ()
 
VectorType::const_iterator end () const
 

Private Attributes

VectorType & v
 
const unsigned int start
 
const unsigned int length
 

Related Functions

(Note that these are not member functions.)

template<typename VectorType >
const VectorSlice< const VectorType > make_slice (VectorType &v)
 
template<typename VectorType >
const VectorSlice< const VectorType > make_slice (VectorType &v, const unsigned int start, const unsigned int length)
 

Detailed Description

template<typename VectorType>
class VectorSlice< VectorType >

Filter a range out of any object having a random access operator[] (unsigned int) and a function size() const.

The use of this object is straightforward. It duplicates the random access operator of the VectorType and adds an offset to every index.

Some precautions have to be taken if it is used for a constant vector: the VectorSlice object has to be constant, too. The appropriate initialization sequence is like this:

void f(const std::vector<int>& v)
{
const VectorSlice<const std::vector<int> > slice(v,...);
...
}
Author
Guido Kanschat, 2004

Definition at line 50 of file vector_slice.h.

Constructor & Destructor Documentation

template<typename VectorType >
VectorSlice< VectorType >::VectorSlice ( VectorType &  v)
inline

Construct a vector slice containing the whole vector. Comes handy, if you did not want to have a slice at all, but the function you call wants it: just put in the vector itself as argument and let this constructor make a slice for you.

Definition at line 174 of file vector_slice.h.

template<typename VectorType >
VectorSlice< VectorType >::VectorSlice ( VectorType &  v,
unsigned int  start,
unsigned int  length 
)
inline

The real constructor for a vector slice, allowing you to specify the start index and the length of the slice.

Definition at line 182 of file vector_slice.h.

Member Function Documentation

template<typename VectorType >
VectorSlice< VectorType >::operator ArrayView< typename VectorType::value_type * > ( )

Conversion operator to an ArrayView object that represents an array of non-const elements pointing to the same location as the current object.

Definition at line 203 of file vector_slice.h.

template<typename VectorType >
VectorSlice< VectorType >::operator ArrayView< const typename VectorType::value_type * > ( ) const

Conversion operator to an ArrayView object that represents an array of const elements pointing to the same location as the current object.

Definition at line 211 of file vector_slice.h.

template<typename VectorType >
unsigned int VectorSlice< VectorType >::size ( ) const
inline

Return the length of the slice using the same interface as std::vector.

Definition at line 196 of file vector_slice.h.

template<typename VectorType >
VectorType::reference VectorSlice< VectorType >::operator[] ( unsigned int  i)
inline

Return a reference to the \(i\)th element of the range represented by the current object.

Definition at line 219 of file vector_slice.h.

template<typename VectorType >
VectorType::const_reference VectorSlice< VectorType >::operator[] ( unsigned int  i) const
inline

Return a const reference to the \(i\)th element of the range represented by the current object.

Definition at line 229 of file vector_slice.h.

template<typename VectorType >
VectorType::iterator VectorSlice< VectorType >::begin ( )
inline

Standard-conforming iterator function.

Definition at line 247 of file vector_slice.h.

template<typename VectorType >
VectorType::const_iterator VectorSlice< VectorType >::begin ( ) const
inline

Standard-conforming iterator function.

Definition at line 239 of file vector_slice.h.

template<typename VectorType >
VectorType::iterator VectorSlice< VectorType >::end ( )
inline

Standard-conforming iterator function.

Definition at line 263 of file vector_slice.h.

template<typename VectorType >
VectorType::const_iterator VectorSlice< VectorType >::end ( ) const
inline

Standard-conforming iterator function.

Definition at line 255 of file vector_slice.h.

Friends And Related Function Documentation

template<typename VectorType >
const VectorSlice< const VectorType > make_slice ( VectorType &  v)
related

Helper function for creating temporary objects without typing template arguments.

Author
Guido Kanschat, 2004

Definition at line 146 of file vector_slice.h.

template<typename VectorType >
const VectorSlice< const VectorType > make_slice ( VectorType &  v,
const unsigned int  start,
const unsigned int  length 
)
related

Helper function for creating temporary objects without typing template arguments.

Author
Guido Kanschat, 2004

Definition at line 163 of file vector_slice.h.

Member Data Documentation

template<typename VectorType>
VectorType& VectorSlice< VectorType >::v
private

The vector we extract from.

Definition at line 125 of file vector_slice.h.

template<typename VectorType>
const unsigned int VectorSlice< VectorType >::start
private

The start index of the slice.

Definition at line 129 of file vector_slice.h.

template<typename VectorType>
const unsigned int VectorSlice< VectorType >::length
private

The length of the slice.

Definition at line 133 of file vector_slice.h.


The documentation for this class was generated from the following file: