DGtal 2.1.0
Loading...
Searching...
No Matches
DGtal::IVector< T, TAlloc, true > Class Template Reference

#include <DGtal/math/MPolynomial.h>

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.

848 : myAllocator(allocator), myVec(allocator)
849 {}
std::vector< TPointer, typename std::allocator_traits< Alloc >::template rebind_alloc< TPointer > > myVec

◆ 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.

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

◆ 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.

858 : myAllocator(allocator), myVec(aSize, 0, allocator)
859 {
860 create(0, aSize, entry);
861 }

◆ 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 {
866 copy_from(v.myVec);
867 }
void copy_from(const std::vector< TPointer, A > &source)

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

◆ ~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 }
void free(Size begin, Size end)
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 915 of file MPolynomial.h.

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

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

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

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< 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));
842 std::allocator_traits<Alloc>::construct(myAllocator, myVec[i], *source[i]);
843 }
844 }

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

◆ 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));
823 std::allocator_traits<Alloc>::construct(myAllocator, myVec[i], entry);
824 }
825 }

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

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

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

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

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

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

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

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

References DGtal::IVector< T, TAlloc, usePointers >::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 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 900 of file MPolynomial.h.

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

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

891 {
892 Size oldsize = (Size)myVec.size();
893 if (oldsize > aSize)
894 free(aSize, oldsize);
895 myVec.resize(aSize);
896 if (oldsize < aSize)
897 create(oldsize, aSize, entry);
898 }
std::vector< TPointer, typenamestd::allocator_traits< Alloc >::templaterebind_alloc< TPointer > >::size_type Size

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

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

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

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

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

◆ 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

Definition at line 814 of file MPolynomial.h.


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