Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
Public Member Functions | Protected Types | Related Functions | List of all members
VectorSlice< VectorType > Class Template Reference

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

Inheritance diagram for VectorSlice< VectorType >:
[legend]

Public Member Functions

 VectorSlice (VectorType &v)
 
 VectorSlice (VectorType &v, unsigned int start, unsigned int length)
 
- Public Member Functions inherited from ArrayView< std::conditional< std::is_const< VectorType >::value, const VectorType::value_type, VectorType::value_type >::type >
 ArrayView ()
 
 ArrayView (value_type *starting_element, const std::size_t n_elements)
 
 ArrayView (const ArrayView< typename std::remove_cv< value_type >::type, MemorySpace::Host > &view)
 
 ArrayView (const std::vector< typename std::remove_cv< value_type >::type > &vector)
 
 ArrayView (std::vector< typename std::remove_cv< value_type >::type > &vector)
 
void reinit (value_type *starting_element, const std::size_t n_elements)
 
bool operator== (const ArrayView< const value_type, MemorySpace::Host > &other_view) const
 
bool operator== (const ArrayView< typename std::remove_cv< value_type >::type, MemorySpace::Host > &other_view) const
 
bool operator!= (const ArrayView< const value_type, MemorySpace::Host > &other_view) const
 
bool operator!= (const ArrayView< typename std::remove_cv< value_type >::type, MemorySpace::Host > &other_view) const
 
std::size_t size () const
 
value_typedata () const noexcept
 
iterator begin () const
 
iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
value_typeoperator[] (const std::size_t i) const
 

Protected Types

using ArrayViewType = ArrayView< typename std::conditional< std::is_const< VectorType >::value, const typename VectorType::value_type, typename VectorType::value_type >::type >
 

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)
 

Additional Inherited Members

- Public Types inherited from ArrayView< std::conditional< std::is_const< VectorType >::value, const VectorType::value_type, VectorType::value_type >::type >
using value_type = std::conditional< std::is_const< VectorType >::value, const VectorType::value_type, VectorType::value_type >::type
 
using iterator = value_type *
 
using const_iterator = const std::conditional< std::is_const< VectorType >::value, const VectorType::value_type, VectorType::value_type >::type *
 

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
Deprecated:
Use the more general ArrayView class instead.

Definition at line 51 of file vector_slice.h.

Member Typedef Documentation

◆ ArrayViewType

template<typename VectorType>
using VectorSlice< VectorType >::ArrayViewType = ArrayView<typename std::conditional<std::is_const<VectorType>::value, const typename VectorType::value_type, typename VectorType::value_type>::type>
protected

Alias for the base class name.

Definition at line 78 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 119 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 126 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 91 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 108 of file vector_slice.h.


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