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

#include <DGtal/math/MPolynomial.h>

Public Types

typedef TAlloc Alloc
 
typedef std::vector< typename Alloc::pointer, typename Alloc::template rebind< typename Alloc::pointer >::other >::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())
 
 IVector (const IVector &v)
 
 ~IVector ()
 
IVectoroperator= (const IVector &v)
 
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 Member Functions

void create (Size begin, Size end, typename Alloc::const_reference entry)
 
void free (Size begin, Size end)
 
template<class A >
void copy_from (const std::vector< typename Alloc::pointer, A > &source)
 

Private Attributes

Alloc myAllocator
 
std::vector< typename Alloc::pointer, typename Alloc::template rebind< typename Alloc::pointer >::other > myVec
 

Detailed Description

template<typename T, typename TAlloc>
class DGtal::IVector< T, TAlloc, true >

Specialization that is using std::vector<T*>, but behaving like std::vector<T>.

Definition at line 803 of file MPolynomial.h.

Member Typedef Documentation

◆ Alloc

template<typename T , typename TAlloc >
typedef TAlloc DGtal::IVector< T, TAlloc, true >::Alloc

Definition at line 806 of file MPolynomial.h.

◆ Size

template<typename T , typename TAlloc >
typedef std::vector<typename Alloc::pointer, typename Alloc::template rebind<typename Alloc::pointer>::other>::size_type DGtal::IVector< T, TAlloc, true >::Size

Definition at line 807 of file MPolynomial.h.

Constructor & Destructor Documentation

◆ IVector() [1/4]

template<typename T , typename TAlloc >
DGtal::IVector< T, TAlloc, true >::IVector ( const Alloc allocator = Alloc())
inline

Definition at line 842 of file MPolynomial.h.

843  : myAllocator(allocator), myVec(allocator)
844  {}
std::vector< typename Alloc::pointer, typename Alloc::template rebind< typename Alloc::pointer >::other > myVec
Definition: MPolynomial.h:811

◆ IVector() [2/4]

template<typename T , typename TAlloc >
DGtal::IVector< T, TAlloc, true >::IVector ( Size  aSize,
const Alloc allocator = Alloc() 
)
inline

Definition at line 846 of file MPolynomial.h.

847  : myAllocator(allocator), myVec(aSize, 0, allocator)
848  {
849  create(0, aSize, T());
850  }
void create(Size begin, Size end, typename Alloc::const_reference entry)
Definition: MPolynomial.h:813

◆ IVector() [3/4]

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

Definition at line 852 of file MPolynomial.h.

853  : myAllocator(allocator), myVec(aSize, 0, allocator)
854  {
855  create(0, aSize, entry);
856  }

◆ IVector() [4/4]

template<typename T , typename TAlloc >
DGtal::IVector< T, TAlloc, true >::IVector ( const IVector< T, TAlloc, true > &  v)
inline

Definition at line 858 of file MPolynomial.h.

859  : myVec(v.size())
860  {
861  copy_from(v.myVec);
862  }
void copy_from(const std::vector< typename Alloc::pointer, A > &source)
Definition: MPolynomial.h:832

◆ ~IVector()

template<typename T , typename TAlloc >
DGtal::IVector< T, TAlloc, true >::~IVector ( )
inline

Definition at line 864 of file MPolynomial.h.

865  {
866  free(0, (Size)myVec.size());
867  }
void free(Size begin, Size end)
Definition: MPolynomial.h:822
HalfEdgeDataStructure::Size Size

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

Member Function Documentation

◆ back() [1/2]

template<typename T , typename TAlloc >
T& DGtal::IVector< T, TAlloc, true >::back ( )
inline

Definition at line 910 of file MPolynomial.h.

911  {
912  return *myVec.back();
913  }

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

◆ back() [2/2]

template<typename T , typename TAlloc >
const T& DGtal::IVector< T, TAlloc, true >::back ( ) const
inline

Definition at line 905 of file MPolynomial.h.

906  {
907  return *myVec.back();
908  }

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

◆ copy_from()

template<typename T , typename TAlloc >
template<class A >
void DGtal::IVector< T, TAlloc, true >::copy_from ( const std::vector< typename Alloc::pointer, A > &  source)
inlineprivate

Definition at line 832 of file MPolynomial.h.

833  {
834  for (Size i = 0; i < myVec.size(); ++i)
835  {
836  myVec[i] = myAllocator.allocate(sizeof(T));
837  myAllocator.construct(myVec[i], *source[i]);
838  }
839  }

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

◆ create()

template<typename T , typename TAlloc >
void DGtal::IVector< T, TAlloc, true >::create ( Size  begin,
Size  end,
typename Alloc::const_reference  entry 
)
inlineprivate

Definition at line 813 of file MPolynomial.h.

814  {
815  for (Size i = begin; i < end; ++i)
816  {
817  myVec[i] = myAllocator.allocate(sizeof(T));
818  myAllocator.construct(myVec[i], entry);
819  }
820  }

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

◆ free()

template<typename T , typename TAlloc >
void DGtal::IVector< T, TAlloc, true >::free ( Size  begin,
Size  end 
)
inlineprivate

Definition at line 822 of file MPolynomial.h.

823  {
824  for (Size i = begin; i < end; ++i)
825  {
826  myAllocator.destroy(myVec[i]);
827  myAllocator.deallocate(myVec[i], sizeof(T));
828  }
829  }

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

◆ get_allocator()

template<typename T , typename TAlloc >
Alloc DGtal::IVector< T, TAlloc, true >::get_allocator ( ) const
inline

Definition at line 920 of file MPolynomial.h.

921  {
922  return myVec.get_allocator();
923  }

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

◆ getAllocator()

template<typename T , typename TAlloc >
Alloc DGtal::IVector< T, TAlloc, true >::getAllocator ( ) const
inline

Definition at line 925 of file MPolynomial.h.

926  {
927  return myVec.get_allocator();
928  }

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

◆ operator=()

template<typename T , typename TAlloc >
IVector& DGtal::IVector< T, TAlloc, true >::operator= ( const IVector< T, TAlloc, true > &  v)
inline

Definition at line 869 of file MPolynomial.h.

870  {
871  if (&v != this)
872  {
873  free(0, (Size)myVec.size());
874  myVec.resize(v.size());
875  copy_from(v.myVec);
876  }
877  return *this;
878  }

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

◆ operator[]() [1/2]

template<typename T , typename TAlloc >
T& DGtal::IVector< T, TAlloc, true >::operator[] ( Size  i)
inline

Definition at line 900 of file MPolynomial.h.

901  {
902  return *myVec[i];
903  }

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

◆ operator[]() [2/2]

template<typename T , typename TAlloc >
const T& DGtal::IVector< T, TAlloc, true >::operator[] ( Size  i) const
inline

Definition at line 895 of file MPolynomial.h.

896  {
897  return *myVec[i];
898  }

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

◆ resize()

template<typename T , typename TAlloc >
void DGtal::IVector< T, TAlloc, true >::resize ( Size  aSize,
const T &  entry = T() 
)
inline

Definition at line 885 of file MPolynomial.h.

886  {
887  Size oldsize = (Size)myVec.size();
888  if (oldsize > aSize)
889  free(aSize, oldsize);
890  myVec.resize(aSize);
891  if (oldsize < aSize)
892  create(oldsize, aSize, entry);
893  }
std::vector< typename Alloc::pointer, typename Alloc::template rebind< typename Alloc::pointer >::other >::size_type Size
Definition: MPolynomial.h:807

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

◆ size()

template<typename T , typename TAlloc >
Size DGtal::IVector< T, TAlloc, true >::size ( ) const
inline

Definition at line 880 of file MPolynomial.h.

881  {
882  return (Size)myVec.size();
883  }

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

◆ swap()

template<typename T , typename TAlloc >
void DGtal::IVector< T, TAlloc, true >::swap ( IVector< T, TAlloc, true > &  v)
inline

Definition at line 915 of file MPolynomial.h.

916  {
917  myVec.swap(v.myVec);
918  }

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

Field Documentation

◆ myAllocator

template<typename T , typename TAlloc >
Alloc DGtal::IVector< T, TAlloc, true >::myAllocator
private

Definition at line 810 of file MPolynomial.h.

◆ myVec

template<typename T , typename TAlloc >
std::vector<typename Alloc::pointer, typename Alloc::template rebind<typename Alloc::pointer>::other> DGtal::IVector< T, TAlloc, true >::myVec
private

Definition at line 811 of file MPolynomial.h.


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