Reference documentation for deal.II version 8.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Private Attributes | Related Functions | List of all members
VectorSlice< VECTOR > Class Template Reference

#include <vector_slice.h>

Public Member Functions

 VectorSlice (VECTOR &v)
 
 VectorSlice (VECTOR &v, unsigned int start, unsigned int length)
 
unsigned int size () const
 
VECTOR::reference operator[] (unsigned int i)
 
VECTOR::const_reference operator[] (unsigned int i) const
 
VECTOR::iterator begin ()
 
VECTOR::const_iterator begin () const
 
VECTOR::iterator end ()
 
VECTOR::const_iterator end () const
 

Private Attributes

VECTOR & v
 
const unsigned int start
 
const unsigned int length
 

Related Functions

(Note that these are not member functions.)

template<class VECTOR >
const VectorSlice< const VECTOR > make_slice (VECTOR &v)
 
template<class VECTOR >
const VectorSlice< const VECTOR > make_slice (VECTOR &v, const unsigned int start, const unsigned int length)
 

Detailed Description

template<class VECTOR>
class VectorSlice< VECTOR >

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 VECTOR 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 initalization 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 38 of file sparsity_pattern.h.

Constructor & Destructor Documentation

template<class VECTOR >
VectorSlice< VECTOR >::VectorSlice ( VECTOR &  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.

template<class VECTOR >
VectorSlice< VECTOR >::VectorSlice ( VECTOR &  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

template<class VECTOR >
unsigned int VectorSlice< VECTOR >::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.

template<class VECTOR >
VECTOR::reference VectorSlice< VECTOR >::operator[] ( unsigned int  i)
inline

Access an element of the slice using the same interface as std::vector.

Definition at line 207 of file vector_slice.h.

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

Access an element of a constant slice using the same interface as std::vector.

Definition at line 218 of file vector_slice.h.

template<class VECTOR >
VECTOR::iterator VectorSlice< VECTOR >::begin ( )
inline

STL conforming iterator function.

Definition at line 238 of file vector_slice.h.

template<class VECTOR >
VECTOR::const_iterator VectorSlice< VECTOR >::begin ( ) const
inline

STL conforming iterator function.

Definition at line 229 of file vector_slice.h.

template<class VECTOR >
VECTOR::iterator VectorSlice< VECTOR >::end ( )
inline

STL conforming iterator function.

Definition at line 256 of file vector_slice.h.

template<class VECTOR >
VECTOR::const_iterator VectorSlice< VECTOR >::end ( ) const
inline

STL conforming iterator function.

Definition at line 247 of file vector_slice.h.

Friends And Related Function Documentation

template<class VECTOR >
const VectorSlice< const VECTOR > make_slice ( VECTOR &  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.

template<class VECTOR >
const VectorSlice< const VECTOR > make_slice ( VECTOR &  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

template<class VECTOR>
VECTOR& VectorSlice< VECTOR >::v
private

The vector we extract from.

Definition at line 121 of file vector_slice.h.

template<class VECTOR>
const unsigned int VectorSlice< VECTOR >::start
private

The start index of the slice.

Definition at line 125 of file vector_slice.h.

template<class VECTOR>
const unsigned int VectorSlice< VECTOR >::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 files: