DGtal 1.3.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes
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 721 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 724 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 725 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 730 of file MPolynomial.h.

731 : myVec(allocator)
732 {}
std::vector< T, Alloc > myVec
Definition: MPolynomial.h:727

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

735 : myVec( aSize, T(), allocator )
736 {}

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

739 : myVec(aSize, entry, allocator)
740 {}

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

768 {
769 return myVec.back();
770 }

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

763 {
764 return myVec.back();
765 }

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

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

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

783 {
784 return myVec.get_allocator();
785 }

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

758 {
759 return myVec[i];
760 }

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

753 {
754 return myVec[i];
755 }

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

◆ resize()

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

◆ size()

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

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

773 {
774 myVec.swap( v.myVec );
775 }

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

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

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: