VectorSlice< VECTOR > Class Template Reference
[Data storage primitives]

List of all members.

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, unsigned int start, 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 reduplicates 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

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.

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.

References Assert.


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.

References VectorSlice< VECTOR >::length.

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.

References Assert, VectorSlice< VECTOR >::length, VectorSlice< VECTOR >::start, and VectorSlice< VECTOR >::v.

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.

References Assert, VectorSlice< VECTOR >::length, VectorSlice< VECTOR >::start, and VectorSlice< VECTOR >::v.

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

STL conforming iterator function.

References VectorSlice< VECTOR >::start, and VectorSlice< VECTOR >::v.

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

STL conforming iterator function.

References VectorSlice< VECTOR >::start, and VectorSlice< VECTOR >::v.

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

STL conforming iterator function.

References VectorSlice< VECTOR >::length, VectorSlice< VECTOR >::start, and VectorSlice< VECTOR >::v.

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

STL conforming iterator function.

References VectorSlice< VECTOR >::length, VectorSlice< VECTOR >::start, and VectorSlice< VECTOR >::v.


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
template<class VECTOR >
const VectorSlice< const VECTOR > make_slice ( VECTOR &  v,
unsigned int  start,
unsigned int  length 
) [related]

Helper function for creating temporary objects without typing template arguments.

Author:
Guido Kanschat, 2004

Member Data Documentation

template<class VECTOR>
VECTOR& VectorSlice< VECTOR >::v [private]
template<class VECTOR>
const unsigned int VectorSlice< VECTOR >::start [private]
template<class VECTOR>
const unsigned int VectorSlice< VECTOR >::length [private]

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

deal.II documentation generated on Mon Nov 23 22:58:17 2009 by doxygen 1.6.1