DGtal 1.3.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes
DGtal::IVector< T, TAlloc, true > Class Template Reference

#include <DGtal/math/MPolynomial.h>

Public Types

typedef TAlloc Alloc
 
typedef std::vector< typenameAlloc::pointer, typenameAlloc::templaterebind< typenameAlloc::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 793 of file MPolynomial.h.

Member Typedef Documentation

◆ Alloc

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

Definition at line 796 of file MPolynomial.h.

◆ Size

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

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

833 : myAllocator(allocator), myVec(allocator)
834 {}
std::vector< typename Alloc::pointer, typename Alloc::template rebind< typename Alloc::pointer >::other > myVec
Definition: MPolynomial.h:801

◆ IVector() [2/4]

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

Definition at line 836 of file MPolynomial.h.

837 : myAllocator(allocator), myVec(aSize, 0, allocator)
838 {
839 create(0, aSize, T());
840 }
void create(Size begin, Size end, typename Alloc::const_reference entry)
Definition: MPolynomial.h:803

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

843 : myAllocator(allocator), myVec(aSize, 0, allocator)
844 {
845 create(0, aSize, entry);
846 }

◆ IVector() [4/4]

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

Definition at line 848 of file MPolynomial.h.

849 : myVec(v.size())
850 {
851 copy_from(v.myVec);
852 }
void copy_from(const std::vector< typename Alloc::pointer, A > &source)
Definition: MPolynomial.h:822

◆ ~IVector()

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

Definition at line 854 of file MPolynomial.h.

855 {
856 free(0, (Size)myVec.size());
857 }
void free(Size begin, Size end)
Definition: MPolynomial.h:812
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 900 of file MPolynomial.h.

901 {
902 return *myVec.back();
903 }

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

896 {
897 return *myVec.back();
898 }

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

823 {
824 for (Size i = 0; i < myVec.size(); ++i)
825 {
826 myVec[i] = myAllocator.allocate(sizeof(T));
827 myAllocator.construct(myVec[i], *source[i]);
828 }
829 }

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

804 {
805 for (Size i = begin; i < end; ++i)
806 {
807 myVec[i] = myAllocator.allocate(sizeof(T));
808 myAllocator.construct(myVec[i], entry);
809 }
810 }

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

813 {
814 for (Size i = begin; i < end; ++i)
815 {
816 myAllocator.destroy(myVec[i]);
817 myAllocator.deallocate(myVec[i], sizeof(T));
818 }
819 }

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

911 {
912 return myVec.get_allocator();
913 }

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

916 {
917 return myVec.get_allocator();
918 }

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

860 {
861 if (&v != this)
862 {
863 free(0, (Size)myVec.size());
864 myVec.resize(v.size());
865 copy_from(v.myVec);
866 }
867 return *this;
868 }

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

891 {
892 return *myVec[i];
893 }

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

886 {
887 return *myVec[i];
888 }

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

876 {
877 Size oldsize = (Size)myVec.size();
878 if (oldsize > aSize)
879 free(aSize, oldsize);
880 myVec.resize(aSize);
881 if (oldsize < aSize)
882 create(oldsize, aSize, entry);
883 }
std::vector< typenameAlloc::pointer, typenameAlloc::templaterebind< typenameAlloc::pointer >::other >::size_type Size
Definition: MPolynomial.h:797

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

871 {
872 return (Size)myVec.size();
873 }

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

906 {
907 myVec.swap(v.myVec);
908 }

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


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