File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/config/TeX-MML-AM_CHTML/MathJax.js
DGtal 2.0.0
DGtal::IVector< T, TAlloc, true > Class Template Reference

#include <DGtal/math/MPolynomial.h>

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

Public Types

typedef TAlloc Alloc
typedef std::allocator_traits< Alloc >::pointer TPointer
typedef std::vector< TPointer, typenamestd::allocator_traits< Alloc >::templaterebind_alloc< TPointer > >::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, const typename Alloc::value_type &entry)
void free (Size begin, Size end)
template<class A>
void copy_from (const std::vector< TPointer, A > &source)

Private Attributes

Alloc myAllocator
std::vector< TPointer, typename std::allocator_traits< Alloc >::template rebind_alloc< TPointer > > 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 805 of file MPolynomial.h.

Member Typedef Documentation

◆ Alloc

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

Definition at line 808 of file MPolynomial.h.

◆ Size

template<typename T, typename TAlloc>
typedef std::vector<TPointer,typenamestd::allocator_traits<Alloc>::templaterebind_alloc<TPointer>>::size_type DGtal::IVector< T, TAlloc, true >::Size

Definition at line 810 of file MPolynomial.h.

◆ TPointer

template<typename T, typename TAlloc>
typedef std::allocator_traits<Alloc>::pointer DGtal::IVector< T, TAlloc, true >::TPointer

Definition at line 809 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 847 of file MPolynomial.h.

849 {}
std::vector< TPointer, typename std::allocator_traits< Alloc >::template rebind_alloc< TPointer > > myVec

References myAllocator, and myVec.

Referenced by IVector(), operator=(), and swap().

◆ IVector() [2/4]

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

Definition at line 851 of file MPolynomial.h.

853 {
854 create(0, aSize, T());
855 }
void create(Size begin, Size end, const typename Alloc::value_type &entry)

References create(), myAllocator, and myVec.

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

859 {
860 create(0, aSize, entry);
861 }

References create(), myAllocator, and myVec.

◆ IVector() [4/4]

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

Definition at line 863 of file MPolynomial.h.

864 : myVec(v.size())
865 {
867 }
void copy_from(const std::vector< TPointer, A > &source)
Size size() const
std::vector< T, Alloc > myVec

References copy_from(), IVector(), DGtal::IVector< T, TAlloc, usePointers >::myVec, myVec, and size().

◆ ~IVector()

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

Definition at line 869 of file MPolynomial.h.

870 {
871 free(0, (Size)myVec.size());
872 }
std::vector< TPointer, typenamestd::allocator_traits< Alloc >::templaterebind_alloc< TPointer > >::size_type Size
void free(Size begin, Size end)

References free(), and myVec.

Member Function Documentation

◆ back() [1/2]

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

Definition at line 915 of file MPolynomial.h.

916 {
917 return *myVec.back();
918 }

References myVec.

◆ back() [2/2]

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

Definition at line 910 of file MPolynomial.h.

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

References myVec.

◆ copy_from()

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

Definition at line 837 of file MPolynomial.h.

838 {
839 for (Size i = 0; i < myVec.size(); ++i)
840 {
841 myVec[i] = myAllocator.allocate(sizeof(T));
843 }
844 }

References myAllocator, and myVec.

Referenced by IVector(), and operator=().

◆ create()

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

Definition at line 818 of file MPolynomial.h.

819 {
820 for (Size i = begin; i < end; ++i)
821 {
822 myVec[i] = myAllocator.allocate(sizeof(T));
824 }
825 }

References myAllocator, and myVec.

Referenced by IVector(), IVector(), and resize().

◆ free()

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

Definition at line 827 of file MPolynomial.h.

828 {
829 for (Size i = begin; i < end; ++i)
830 {
832 myAllocator.deallocate(myVec[i], sizeof(T));
833 }
834 }

References myAllocator, and myVec.

Referenced by operator=(), resize(), and ~IVector().

◆ get_allocator()

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

Definition at line 925 of file MPolynomial.h.

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

References myVec.

◆ getAllocator()

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

Definition at line 930 of file MPolynomial.h.

931 {
932 return myVec.get_allocator();
933 }

References myVec.

◆ operator=()

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

Definition at line 874 of file MPolynomial.h.

875 {
876 if (&v != this)
877 {
878 free(0, (Size)myVec.size());
879 myVec.resize(v.size());
881 }
882 return *this;
883 }

References copy_from(), free(), IVector(), DGtal::IVector< T, TAlloc, usePointers >::myVec, myVec, and DGtal::IVector< T, TAlloc, usePointers >::size().

◆ operator[]() [1/2]

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

Definition at line 905 of file MPolynomial.h.

906 {
907 return *myVec[i];
908 }

References myVec.

◆ operator[]() [2/2]

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

Definition at line 900 of file MPolynomial.h.

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

References myVec.

◆ resize()

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

Definition at line 890 of file MPolynomial.h.

891 {
892 Size oldsize = (Size)myVec.size();
893 if (oldsize > aSize)
895 myVec.resize(aSize);
896 if (oldsize < aSize)
898 }

References create(), free(), and myVec.

◆ size()

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

Definition at line 885 of file MPolynomial.h.

886 {
887 return (Size)myVec.size();
888 }

References myVec.

Referenced by IVector().

◆ swap()

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

Definition at line 920 of file MPolynomial.h.

921 {
922 myVec.swap(v.myVec);
923 }

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

Field Documentation

◆ myAllocator

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

Definition at line 813 of file MPolynomial.h.

Referenced by copy_from(), create(), free(), IVector(), IVector(), and IVector().

◆ myVec

template<typename T, typename TAlloc>
std::vector<TPointer, typename std::allocator_traits<Alloc>::template rebind_alloc<TPointer> > DGtal::IVector< T, TAlloc, true >::myVec
private

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