DGtal  1.5.beta
DGtal::IVector< T, TAlloc, usePointers > Class Template Reference

#include <DGtal/math/MPolynomial.h>

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 731 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 734 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 735 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 740 of file MPolynomial.h.

741  : myVec(allocator)
742  {}
std::vector< T, Alloc > myVec
Definition: MPolynomial.h:737

◆ 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 744 of file MPolynomial.h.

745  : myVec( aSize, T(), allocator )
746  {}

◆ 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 748 of file MPolynomial.h.

749  : myVec(aSize, entry, allocator)
750  {}

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 777 of file MPolynomial.h.

778  {
779  return myVec.back();
780  }

References DGtal::IVector< T, TAlloc, usePointers >::myVec.

◆ 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 772 of file MPolynomial.h.

773  {
774  return myVec.back();
775  }

References DGtal::IVector< T, TAlloc, usePointers >::myVec.

Referenced by DGtal::MPolynomial< n, TRing, TAlloc >::leading().

◆ 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 787 of file MPolynomial.h.

788  {
789  return myVec.get_allocator();
790  }

References DGtal::IVector< T, TAlloc, usePointers >::myVec.

◆ getAllocator()

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

Definition at line 792 of file MPolynomial.h.

793  {
794  return myVec.get_allocator();
795  }

References DGtal::IVector< T, TAlloc, usePointers >::myVec.

Referenced by DGtal::MPolynomial< n, TRing, TAlloc >::getAllocator().

◆ 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 767 of file MPolynomial.h.

768  {
769  return myVec[i];
770  }

References DGtal::IVector< T, TAlloc, usePointers >::myVec.

◆ 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 762 of file MPolynomial.h.

763  {
764  return myVec[i];
765  }

References DGtal::IVector< T, TAlloc, usePointers >::myVec.

◆ 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 782 of file MPolynomial.h.

783  {
784  myVec.swap( v.myVec );
785  }

References DGtal::IVector< T, TAlloc, usePointers >::myVec.

Referenced by DGtal::MPolynomial< n, TRing, TAlloc >::swap().

Field Documentation

◆ myVec


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