Reference documentation for deal.II version 8.5.1
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)
{
...
}
Author
Guido Kanschat, 2004

Definition at line 49 of file vector_slice.h.

Constructor & Destructor Documentation

◆ VectorSlice() [1/2]

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 176 of file vector_slice.h.

◆ VectorSlice() [2/2]

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 184 of file vector_slice.h.

Member Function Documentation

◆ operator ArrayView< typename VectorType::value_type * >()

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 206 of file vector_slice.h.

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

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 214 of file vector_slice.h.

◆ size()

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 198 of file vector_slice.h.

◆ operator[]() [1/2]

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 223 of file vector_slice.h.

◆ operator[]() [2/2]

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 234 of file vector_slice.h.

◆ begin() [1/2]

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

Standard-conforming iterator function.

Definition at line 254 of file vector_slice.h.

◆ begin() [2/2]

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

Standard-conforming iterator function.

Definition at line 245 of file vector_slice.h.

◆ end() [1/2]

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

Standard-conforming iterator function.

Definition at line 272 of file vector_slice.h.

◆ end() [2/2]

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

Standard-conforming iterator function.

Definition at line 263 of file vector_slice.h.

Friends And Related Function Documentation

◆ make_slice() [1/2]

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 143 of file vector_slice.h.

◆ make_slice() [2/2]

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 161 of file vector_slice.h.

Member Data Documentation

◆ v

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

The vector we extract from.

Definition at line 121 of file vector_slice.h.

◆ start

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

The start index of the slice.

Definition at line 125 of file vector_slice.h.

◆ length

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

The length of the slice.

Definition at line 129 of file vector_slice.h.


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