Loading [MathJax]/extensions/MathMenu.js
DGtal 2.0.0
DGtal::IVector< T, TAlloc, usePointers > Class Template Reference

#include <DGtal/math/MPolynomial.h>

Inheritance diagram for DGtal::IVector< T, TAlloc, usePointers >:
[legend]

Public Types

typedef TAlloc Alloc
typedef std::vector< T, Alloc >::size_type Size

Public Member Functions

 IVector (const Alloc &allocator=Alloc())
 IVector (Size aSize, const Alloc &allocator=Alloc())
 IVector (Size aSize, const T &entry, const Alloc &allocator=Alloc())
Size size () const
void resize (Size aSize, const T &entry=T())
const T & operator[] (Size i) const
T & operator[] (Size i)
const T & back () const
T & back ()
void swap (IVector &v)
Alloc get_allocator () const
Alloc getAllocator () const

Private Attributes

std::vector< T, AllocmyVec

Detailed Description

template<typename T, typename TAlloc = std::allocator<T>, bool usePointers = false>
class DGtal::IVector< T, TAlloc, usePointers >

Next, we want to define the storage class IVector<T, Alloc, usePointers>. It behaves like a subset of std::vector<T>'s capabilities (i.e. access elements, get size, set size, get last element, swap with other storage of same type), but uses std::vector<T*> in case usePointers is true.

The advantage of this approach is that if T is a more complex object, reallocation done with resize() can be very costly.

This generic version is just using std::vector<T>.

Definition at line 733 of file MPolynomial.h.

Member Typedef Documentation

◆ Alloc

template<typename T, typename TAlloc = std::allocator<T>, bool usePointers = false>
typedef TAlloc DGtal::IVector< T, TAlloc, usePointers >::Alloc

Definition at line 736 of file MPolynomial.h.

◆ Size

template<typename T, typename TAlloc = std::allocator<T>, bool usePointers = false>
typedef std::vector<T,Alloc>::size_type DGtal::IVector< T, TAlloc, usePointers >::Size

Definition at line 737 of file MPolynomial.h.

Constructor & Destructor Documentation

◆ IVector() [1/3]

template<typename T, typename TAlloc = std::allocator<T>, bool usePointers = false>
DGtal::IVector< T, TAlloc, usePointers >::IVector ( const Alloc & allocator = Alloc())
inline

Definition at line 742 of file MPolynomial.h.

744 {}
std::vector< T, Alloc > myVec

◆ IVector() [2/3]

template<typename T, typename TAlloc = std::allocator<T>, bool usePointers = false>
DGtal::IVector< T, TAlloc, usePointers >::IVector ( Size aSize,
const Alloc & allocator = Alloc() )
inline

Definition at line 746 of file MPolynomial.h.

747 : myVec( aSize, T(), allocator )
748 {}

◆ IVector() [3/3]

template<typename T, typename TAlloc = std::allocator<T>, bool usePointers = false>
DGtal::IVector< T, TAlloc, usePointers >::IVector ( Size aSize,
const T & entry,
const Alloc & allocator = Alloc() )
inline

Definition at line 750 of file MPolynomial.h.

752 {}

Member Function Documentation

◆ back() [1/2]

template<typename T, typename TAlloc = std::allocator<T>, bool usePointers = false>
T & DGtal::IVector< T, TAlloc, usePointers >::back ( )
inline

Definition at line 779 of file MPolynomial.h.

780 {
781 return myVec.back();
782 }

◆ back() [2/2]

template<typename T, typename TAlloc = std::allocator<T>, bool usePointers = false>
const T & DGtal::IVector< T, TAlloc, usePointers >::back ( ) const
inline

Definition at line 774 of file MPolynomial.h.

775 {
776 return myVec.back();
777 }

◆ get_allocator()

template<typename T, typename TAlloc = std::allocator<T>, bool usePointers = false>
Alloc DGtal::IVector< T, TAlloc, usePointers >::get_allocator ( ) const
inline

Definition at line 789 of file MPolynomial.h.

790 {
791 return myVec.get_allocator();
792 }

◆ getAllocator()

template<typename T, typename TAlloc = std::allocator<T>, bool usePointers = false>
Alloc DGtal::IVector< T, TAlloc, usePointers >::getAllocator ( ) const
inline

Definition at line 794 of file MPolynomial.h.

795 {
796 return myVec.get_allocator();
797 }

◆ operator[]() [1/2]

template<typename T, typename TAlloc = std::allocator<T>, bool usePointers = false>
T & DGtal::IVector< T, TAlloc, usePointers >::operator[] ( Size i)
inline

Definition at line 769 of file MPolynomial.h.

770 {
771 return myVec[i];
772 }

◆ operator[]() [2/2]

template<typename T, typename TAlloc = std::allocator<T>, bool usePointers = false>
const T & DGtal::IVector< T, TAlloc, usePointers >::operator[] ( Size i) const
inline

Definition at line 764 of file MPolynomial.h.

765 {
766 return myVec[i];
767 }

◆ resize()

◆ size()

◆ swap()

template<typename T, typename TAlloc = std::allocator<T>, bool usePointers = false>
void DGtal::IVector< T, TAlloc, usePointers >::swap ( IVector< T, TAlloc, usePointers > & v)
inline

Definition at line 784 of file MPolynomial.h.

785 {
786 myVec.swap( v.myVec );
787 }

Field Documentation

◆ myVec

template<typename T, typename TAlloc = std::allocator<T>, bool usePointers = false>
std::vector<T, Alloc> DGtal::IVector< T, TAlloc, usePointers >::myVec
private

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