DGtal  0.9.3beta
Public Types | Public Member Functions | Private Attributes
DGtal::IVector< T, TAlloc, usePointers > Class Template Reference

#include <DGtal/math/MPolynomial.h>

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

Member Typedef Documentation

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.

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

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
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  {}
std::vector< T, Alloc > myVec
Definition: MPolynomial.h:727
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  {}
std::vector< T, Alloc > myVec
Definition: MPolynomial.h:727

Member Function Documentation

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  }
std::vector< T, Alloc > myVec
Definition: MPolynomial.h:727
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  }
std::vector< T, Alloc > myVec
Definition: MPolynomial.h:727
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  }
std::vector< T, Alloc > myVec
Definition: MPolynomial.h:727
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  }
std::vector< T, Alloc > myVec
Definition: MPolynomial.h:727
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  }
std::vector< T, Alloc > myVec
Definition: MPolynomial.h:727
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  }
std::vector< T, Alloc > myVec
Definition: MPolynomial.h:727
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

Definition at line 747 of file MPolynomial.h.

748  {
749  myVec.resize(aSize, entry);
750  }
std::vector< T, Alloc > myVec
Definition: MPolynomial.h:727
template<typename T , typename TAlloc = std::allocator<T>, bool usePointers = false>
Size DGtal::IVector< T, TAlloc, usePointers >::size ( ) const
inline

Definition at line 742 of file MPolynomial.h.

Referenced by DGtal::IVector< T, TAlloc, true >::operator=().

743  {
744  return myVec.size();
745  }
std::vector< T, Alloc > myVec
Definition: MPolynomial.h:727
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.

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

773  {
774  myVec.swap( v.myVec );
775  }
std::vector< T, Alloc > myVec
Definition: MPolynomial.h:727

Field Documentation

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: