MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
grad::RangeVector< T, 0 > Class Template Reference

#include <gradient.h>

Inheritance diagram for grad::RangeVector< T, 0 >:
Collaboration diagram for grad::RangeVector< T, 0 >:

Classes

struct  Data
 

Public Types

typedef RangeVectorBase< T, 0 >
::scalar_type 
scalar_type
 
typedef RangeVectorBase< T, 0 >
::vector_type 
vector_type
 
- Public Types inherited from grad::RangeVectorBase< T, 0 >
typedef T vector_type
 
typedef T scalar_type
 

Public Member Functions

 RangeVector ()
 
 RangeVector (const RangeVector &v)
 
template<typename T2 , index_type N_SIZE2>
 RangeVector (const RangeVector< T2, N_SIZE2 > &v)
 
 RangeVector (index_type iStart, index_type iEnd, const scalar_type &dVal)
 
 ~RangeVector ()
 
RangeVectoroperator= (const RangeVector &v)
 
template<typename T2 , index_type N_SIZE2>
RangeVectoroperator= (const RangeVector< T2, N_SIZE2 > &v)
 
void ResizeReset (index_type iStartNew, index_type iEndNew, const scalar_type &dVal)
 
void ResizePreserve (index_type iStartNew, index_type iEndNew)
 
void Reset ()
 
void Reserve (index_type iMaxSize)
 
index_type iGetStartIndex () const
 
index_type iGetEndIndex () const
 
index_type iGetStartIndexVector () const
 
index_type iGetEndIndexVector () const
 
index_type iGetSizeVector () const
 
index_type iGetSize () const
 
scalar_type GetValue (index_type i) const
 
void SetValue (index_type i, const scalar_type &d)
 
vector_type GetVectorValue (index_type i) const
 
void SetVectorValue (index_type i, const vector_type &d)
 

Static Public Member Functions

static index_type iGetMaxSize ()
 
static index_type iGetMaxSizeVector ()
 
static bool bUseDynamicMem ()
 
- Static Public Member Functions inherited from grad::RangeVectorBase< T, 0 >
static index_type iRoundStartIndexVector (index_type iStart)
 
static index_type iRoundEndIndexVector (index_type iEnd)
 

Static Public Attributes

static const index_type iVectorSize = RangeVectorBase<T, 0>::iVectorSize
 
static const index_type iMaxSize = IntegerTypeTraits<index_type>::iMaxValue / sizeof(scalar_type)
 
static const index_type iMaxSizeVector = iMaxSize / iVectorSize
 
- Static Public Attributes inherited from grad::RangeVectorBase< T, 0 >
static const int iVectorSize
 

Private Types

enum  MemFlags { RESIZE, RESERVE }
 

Private Member Functions

index_type iGetCapacity () const
 
index_type iGetCapacityVector () const
 
template<typename T2 , index_type N_SIZE2>
void Copy (const RangeVector< T2, N_SIZE2 > &v)
 
void Copy (const RangeVector &v)
 
void Initialize (index_type iStart, index_type iEnd, const scalar_type &dVal)
 
scalar_typebegin ()
 
scalar_typeend ()
 
const scalar_typebegin () const
 
const scalar_typeend () const
 
vector_typebeginVec ()
 
vector_typeendVec ()
 
const vector_typebeginVec () const
 
const vector_typeendVec () const
 
void ReserveMem (index_type iStartNew, index_type iEndNew, MemFlags eFlags=RESIZE)
 
void FreeMem ()
 

Static Private Member Functions

static Data * pNullData ()
 

Private Attributes

Data * pData
 

Static Private Attributes

static const Data sNullData = {0}
 

Detailed Description

template<typename T>
class grad::RangeVector< T, 0 >

Definition at line 645 of file gradient.h.

Member Typedef Documentation

template<typename T >
typedef RangeVectorBase<T, 0>::scalar_type grad::RangeVector< T, 0 >::scalar_type

Definition at line 648 of file gradient.h.

template<typename T >
typedef RangeVectorBase<T, 0>::vector_type grad::RangeVector< T, 0 >::vector_type

Definition at line 649 of file gradient.h.

Member Enumeration Documentation

template<typename T >
enum grad::RangeVector< T, 0 >::MemFlags
private
Enumerator
RESIZE 
RESERVE 

Definition at line 899 of file gradient.h.

Constructor & Destructor Documentation

template<typename T >
grad::RangeVector< T, 0 >::RangeVector ( )
inline

Definition at line 655 of file gradient.h.

References GRADIENT_ASSERT.

656  :pData(pNullData()) {
657  GRADIENT_ASSERT(bInvariant());
658  }
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
static Data * pNullData()
Definition: gradient.h:976
template<typename T >
grad::RangeVector< T, 0 >::RangeVector ( const RangeVector< T, 0 > &  v)
inline

Definition at line 660 of file gradient.h.

References grad::RangeVector< T, N_SIZE >::Copy(), GRADIENT_ASSERT, grad::RangeVector< T, N_SIZE >::iGetEndIndex(), and grad::RangeVector< T, N_SIZE >::iGetStartIndex().

661  :pData(pNullData()) {
662  ReserveMem(v.iGetStartIndex(), v.iGetEndIndex(), RESIZE);
663  Copy(v);
664 
665  GRADIENT_ASSERT(bInvariant());
666  }
void ReserveMem(index_type iStartNew, index_type iEndNew, MemFlags eFlags=RESIZE)
Definition: gradient.h:937
void Copy(const RangeVector< T2, N_SIZE2 > &v)
Definition: gradient.h:880
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
static Data * pNullData()
Definition: gradient.h:976

Here is the call graph for this function:

template<typename T >
template<typename T2 , index_type N_SIZE2>
grad::RangeVector< T, 0 >::RangeVector ( const RangeVector< T2, N_SIZE2 > &  v)
inline

Definition at line 669 of file gradient.h.

References grad::RangeVector< T, N_SIZE >::Copy(), GRADIENT_ASSERT, grad::RangeVector< T, N_SIZE >::iGetEndIndex(), and grad::RangeVector< T, N_SIZE >::iGetStartIndex().

670  :pData(pNullData()) {
671  ReserveMem(v.iGetStartIndex(), v.iGetEndIndex(), RESIZE);
672  Copy(v);
673 
674  GRADIENT_ASSERT(bInvariant());
675  }
void ReserveMem(index_type iStartNew, index_type iEndNew, MemFlags eFlags=RESIZE)
Definition: gradient.h:937
void Copy(const RangeVector< T2, N_SIZE2 > &v)
Definition: gradient.h:880
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
static Data * pNullData()
Definition: gradient.h:976

Here is the call graph for this function:

template<typename T >
grad::RangeVector< T, 0 >::RangeVector ( index_type  iStart,
index_type  iEnd,
const scalar_type dVal 
)
inlineexplicit

Definition at line 677 of file gradient.h.

References GRADIENT_ASSERT, and grad::RangeVector< T, N_SIZE >::Initialize().

678  :pData(pNullData()) {
679  ReserveMem(iStart, iEnd, RESIZE);
680  Initialize(iStart, iEnd, dVal);
681 
682  GRADIENT_ASSERT(bInvariant());
683  }
void ReserveMem(index_type iStartNew, index_type iEndNew, MemFlags eFlags=RESIZE)
Definition: gradient.h:937
void Initialize(index_type iStart, index_type iEnd, const scalar_type &dVal)
Definition: gradient.h:890
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
static Data * pNullData()
Definition: gradient.h:976

Here is the call graph for this function:

template<typename T >
grad::RangeVector< T, 0 >::~RangeVector ( )
inline

Definition at line 685 of file gradient.h.

References GRADIENT_ASSERT.

685  {
686  GRADIENT_ASSERT(bInvariant());
687 
688  FreeMem();
689  }
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74

Member Function Documentation

template<typename T >
scalar_type* grad::RangeVector< T, 0 >::begin ( void  )
inlineprivate

Definition at line 905 of file gradient.h.

905  {
906  return pData->rgArray;
907  }
template<typename T >
const scalar_type* grad::RangeVector< T, 0 >::begin ( void  ) const
inlineprivate

Definition at line 913 of file gradient.h.

913  {
914  return pData->rgArray;
915  }
template<typename T >
vector_type* grad::RangeVector< T, 0 >::beginVec ( )
inlineprivate

Definition at line 921 of file gradient.h.

Referenced by ResizePreserve().

921  {
922  return pData->rgArrayVec;
923  }
template<typename T >
const vector_type* grad::RangeVector< T, 0 >::beginVec ( ) const
inlineprivate

Definition at line 929 of file gradient.h.

929  {
930  return pData->rgArrayVec;
931  }
template<typename T >
static bool grad::RangeVector< T, 0 >::bUseDynamicMem ( )
inlinestatic

Definition at line 848 of file gradient.h.

848 { return true; }
template<typename T >
template<typename T2 , index_type N_SIZE2>
void grad::RangeVector< T, 0 >::Copy ( const RangeVector< T2, N_SIZE2 > &  v)
inlineprivate

Definition at line 880 of file gradient.h.

References grad::RangeVector< T, N_SIZE >::GetValue(), grad::RangeVector< T, N_SIZE >::iGetEndIndex(), grad::RangeVector< T, N_SIZE >::iGetStartIndex(), and grad::RangeVector< T, N_SIZE >::SetValue().

880  {
881  for (index_type i = iGetStartIndex(); i < iGetEndIndex(); ++i) {
882  SetValue(i, v.GetValue(i));
883  }
884  }
index_type iGetEndIndex() const
Definition: gradient.h:791
index_type iGetStartIndex() const
Definition: gradient.h:787
integer index_type
Definition: gradient.h:104
void SetValue(index_type i, const scalar_type &d)
Definition: gradient.h:823

Here is the call graph for this function:

template<typename T >
void grad::RangeVector< T, 0 >::Copy ( const RangeVector< T, 0 > &  v)
inlineprivate

Definition at line 886 of file gradient.h.

References grad::array_copy().

886  {
887  array_copy(v.beginVec(), v.endVec(), beginVec());
888  }
vector_type * beginVec()
Definition: gradient.h:921
T * array_copy(const T *first, const T *const last, T *result)
Definition: gradient.h:316

Here is the call graph for this function:

template<typename T >
scalar_type* grad::RangeVector< T, 0 >::end ( void  )
inlineprivate

Definition at line 909 of file gradient.h.

References grad::RangeVector< T, N_SIZE >::iGetSize().

909  {
910  return begin() + iGetSize();
911  }
index_type iGetSize() const
Definition: gradient.h:807
scalar_type * begin()
Definition: gradient.h:905

Here is the call graph for this function:

template<typename T >
const scalar_type* grad::RangeVector< T, 0 >::end ( void  ) const
inlineprivate

Definition at line 917 of file gradient.h.

References grad::RangeVector< T, N_SIZE >::iGetSize().

917  {
918  return begin() + iGetSize();
919  }
index_type iGetSize() const
Definition: gradient.h:807
scalar_type * begin()
Definition: gradient.h:905

Here is the call graph for this function:

template<typename T >
vector_type* grad::RangeVector< T, 0 >::endVec ( )
inlineprivate

Definition at line 925 of file gradient.h.

References grad::RangeVector< T, N_SIZE >::iGetSizeVector().

925  {
926  return beginVec() + iGetSizeVector();
927  }
index_type iGetSizeVector() const
Definition: gradient.h:803
vector_type * beginVec()
Definition: gradient.h:921

Here is the call graph for this function:

template<typename T >
const vector_type* grad::RangeVector< T, 0 >::endVec ( ) const
inlineprivate

Definition at line 933 of file gradient.h.

References grad::RangeVector< T, N_SIZE >::iGetSizeVector().

933  {
934  return beginVec() + iGetSizeVector();
935  }
index_type iGetSizeVector() const
Definition: gradient.h:803
vector_type * beginVec()
Definition: gradient.h:921

Here is the call graph for this function:

template<typename T >
void grad::RangeVector< T, 0 >::FreeMem ( )
inlineprivate

Definition at line 969 of file gradient.h.

References grad::GradientAllocator< T >::deallocate_aligned().

969  {
970  if (pData != pNullData()) {
972  pData = pNullData();
973  }
974  }
static void deallocate_aligned(pointer p, size_type n)
Definition: gradient.h:239
static Data * pNullData()
Definition: gradient.h:976

Here is the call graph for this function:

template<typename T >
scalar_type grad::RangeVector< T, 0 >::GetValue ( index_type  i) const
inline

Definition at line 814 of file gradient.h.

References GRADIENT_ASSERT, grad::RangeVector< T, N_SIZE >::iGetEndIndex(), grad::RangeVector< T, N_SIZE >::iGetMaxSize(), grad::RangeVector< T, N_SIZE >::iGetStartIndex(), grad::RangeVector< T, N_SIZE >::iGetStartIndexVector(), grad::RangeVector< T, N_SIZE >::iVectorSize, and grad::RangeVectorTraits< T >::Zero().

814  {
815  GRADIENT_ASSERT(i >= 0);
817 
818  return i >= iGetStartIndex() && i < iGetEndIndex()
821  }
index_type iGetEndIndex() const
Definition: gradient.h:791
index_type iGetStartIndex() const
Definition: gradient.h:787
scalar_type * begin()
Definition: gradient.h:905
static const index_type iVectorSize
Definition: gradient.h:647
static index_type iGetMaxSize()
Definition: gradient.h:811
index_type iGetStartIndexVector() const
Definition: gradient.h:795
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74

Here is the call graph for this function:

template<typename T >
vector_type grad::RangeVector< T, 0 >::GetVectorValue ( index_type  i) const
inline

Definition at line 831 of file gradient.h.

References GRADIENT_ASSERT, grad::RangeVector< T, N_SIZE >::iGetEndIndexVector(), grad::RangeVector< T, N_SIZE >::iGetStartIndexVector(), grad::RangeVector< T, N_SIZE >::iMaxSizeVector, and grad::RangeVectorTraits< T >::Zero().

831  {
832  GRADIENT_ASSERT(i >= 0);
834 
835  return i >= iGetStartIndexVector() && i < iGetEndIndexVector()
836  ? beginVec()[i - iGetStartIndexVector()]
838  }
index_type iGetEndIndexVector() const
Definition: gradient.h:799
static const index_type iMaxSizeVector
Definition: gradient.h:653
vector_type * beginVec()
Definition: gradient.h:921
index_type iGetStartIndexVector() const
Definition: gradient.h:795
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74

Here is the call graph for this function:

template<typename T >
index_type grad::RangeVector< T, 0 >::iGetCapacity ( ) const
inlineprivate

Definition at line 869 of file gradient.h.

References grad::RangeVector< T, N_SIZE >::iVectorSize.

870  {
871  return iGetCapacityVector() * iVectorSize;
872  }
index_type iGetCapacityVector() const
Definition: gradient.h:874
static const index_type iVectorSize
Definition: gradient.h:647
template<typename T >
index_type grad::RangeVector< T, 0 >::iGetCapacityVector ( ) const
inlineprivate

Definition at line 874 of file gradient.h.

875  {
876  return pData->iCapacityVec;
877  }
template<typename T >
index_type grad::RangeVector< T, 0 >::iGetEndIndex ( ) const
inline

Definition at line 791 of file gradient.h.

791  {
792  return pData->iEnd;
793  }
template<typename T >
index_type grad::RangeVector< T, 0 >::iGetEndIndexVector ( ) const
inline

Definition at line 799 of file gradient.h.

Referenced by ResizePreserve().

799  {
800  return pData->iEndVec;
801  }
template<typename T >
static index_type grad::RangeVector< T, 0 >::iGetMaxSize ( )
inlinestatic

Definition at line 811 of file gradient.h.

References grad::RangeVector< T, N_SIZE >::iMaxSize.

811 { return iMaxSize; }
static const index_type iMaxSize
Definition: gradient.h:651
template<typename T >
static index_type grad::RangeVector< T, 0 >::iGetMaxSizeVector ( )
inlinestatic

Definition at line 812 of file gradient.h.

References grad::RangeVector< T, N_SIZE >::iMaxSizeVector.

812 { return iMaxSizeVector; }
static const index_type iMaxSizeVector
Definition: gradient.h:653
template<typename T >
index_type grad::RangeVector< T, 0 >::iGetSize ( ) const
inline

Definition at line 807 of file gradient.h.

807  {
808  return pData->iEnd - pData->iStart;
809  }
template<typename T >
index_type grad::RangeVector< T, 0 >::iGetSizeVector ( ) const
inline

Definition at line 803 of file gradient.h.

803  {
804  return pData->iEndVec - pData->iStartVec;
805  }
template<typename T >
index_type grad::RangeVector< T, 0 >::iGetStartIndex ( ) const
inline

Definition at line 787 of file gradient.h.

787  {
788  return pData->iStart;
789  }
template<typename T >
index_type grad::RangeVector< T, 0 >::iGetStartIndexVector ( ) const
inline

Definition at line 795 of file gradient.h.

Referenced by ResizePreserve().

795  {
796  return pData->iStartVec;
797  }
template<typename T >
void grad::RangeVector< T, 0 >::Initialize ( index_type  iStart,
index_type  iEnd,
const scalar_type dVal 
)
inlineprivate

Definition at line 890 of file gradient.h.

References grad::array_fill(), grad::RangeVector< T, N_SIZE >::iGetStartIndexVector(), and grad::RangeVector< T, N_SIZE >::Reset().

890  {
891  Reset();
892 
893  if (dVal != RangeVectorTraits<scalar_type>::Zero())
894  {
896  }
897  }
scalar_type * begin()
Definition: gradient.h:905
static const index_type iVectorSize
Definition: gradient.h:647
index_type iGetStartIndexVector() const
Definition: gradient.h:795
void array_fill(T *first, T *const last, const T &val)
Definition: gradient.h:309

Here is the call graph for this function:

template<typename T >
RangeVector& grad::RangeVector< T, 0 >::operator= ( const RangeVector< T, 0 > &  v)
inline

Definition at line 691 of file gradient.h.

References grad::RangeVector< T, N_SIZE >::Copy(), GRADIENT_ASSERT, grad::RangeVector< T, N_SIZE >::iGetEndIndex(), and grad::RangeVector< T, N_SIZE >::iGetStartIndex().

691  {
692  GRADIENT_ASSERT(bInvariant());
693 
694  ReserveMem(v.iGetStartIndex(), v.iGetEndIndex(), RESIZE);
695  Copy(v);
696 
697  GRADIENT_ASSERT(bInvariant());
698 
699  return *this;
700  }
void ReserveMem(index_type iStartNew, index_type iEndNew, MemFlags eFlags=RESIZE)
Definition: gradient.h:937
void Copy(const RangeVector< T2, N_SIZE2 > &v)
Definition: gradient.h:880
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74

Here is the call graph for this function:

template<typename T >
template<typename T2 , index_type N_SIZE2>
RangeVector& grad::RangeVector< T, 0 >::operator= ( const RangeVector< T2, N_SIZE2 > &  v)
inline

Definition at line 703 of file gradient.h.

References grad::RangeVector< T, N_SIZE >::Copy(), GRADIENT_ASSERT, grad::RangeVector< T, N_SIZE >::iGetEndIndex(), and grad::RangeVector< T, N_SIZE >::iGetStartIndex().

703  {
704  GRADIENT_ASSERT(bInvariant());
705 
706  ReserveMem(v.iGetStartIndex(), v.iGetEndIndex(), RESIZE);
707  Copy(v);
708 
709  GRADIENT_ASSERT(bInvariant());
710 
711  return *this;
712  }
void ReserveMem(index_type iStartNew, index_type iEndNew, MemFlags eFlags=RESIZE)
Definition: gradient.h:937
void Copy(const RangeVector< T2, N_SIZE2 > &v)
Definition: gradient.h:880
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74

Here is the call graph for this function:

template<typename T >
static Data* grad::RangeVector< T, 0 >::pNullData ( )
inlinestaticprivate

Definition at line 976 of file gradient.h.

References GRADIENT_ASSERT.

977  {
983 
984  return const_cast<Data*>(&sNullData);
985  }
static const Data sNullData
Definition: gradient.h:1012
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
template<typename T >
void grad::RangeVector< T, 0 >::Reserve ( index_type  iMaxSize)
inline

Definition at line 762 of file gradient.h.

References GRADIENT_ASSERT, grad::RangeVector< T, N_SIZE >::iGetSizeVector(), and grad::RangeVector< T, N_SIZE >::Reserve().

762  {
763  GRADIENT_ASSERT(bInvariant());
764 
765  const index_type iCurrCap = iGetCapacity();
766 
767  if (iCurrCap >= iMaxSize) {
768  return;
769  }
770 
771  if (iGetSizeVector() > 0) {
772  RangeVector oTmpVec;
773 
774  GRADIENT_ASSERT(oTmpVec.iGetSizeVector() == 0);
775 
776  oTmpVec.Reserve(iMaxSize);
777  oTmpVec = *this;
778 
779  std::swap(pData, oTmpVec.pData);
780  } else {
782  }
783 
784  GRADIENT_ASSERT(bInvariant());
785  }
index_type iGetSizeVector() const
Definition: gradient.h:803
void ReserveMem(index_type iStartNew, index_type iEndNew, MemFlags eFlags=RESIZE)
Definition: gradient.h:937
integer index_type
Definition: gradient.h:104
index_type iGetCapacity() const
Definition: gradient.h:869
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
static const index_type iMaxSize
Definition: gradient.h:651

Here is the call graph for this function:

template<typename T >
void grad::RangeVector< T, 0 >::ReserveMem ( index_type  iStartNew,
index_type  iEndNew,
MemFlags  eFlags = RESIZE 
)
inlineprivate

Definition at line 937 of file gradient.h.

References grad::GradientAllocator< T >::allocate_aligned(), GRADIENT_ASSERT, grad::RangeVector< T, N_SIZE >::iEndVec, grad::RangeVectorBase< T, N_SIZE >::iRoundEndIndexVector(), grad::RangeVectorBase< T, N_SIZE >::iRoundStartIndexVector(), and grad::RangeVector< T, N_SIZE >::iStartVec.

Referenced by ResizePreserve().

937  {
938  const index_type iCapCurr = iGetCapacityVector();
939  index_type iStartVec = iRoundStartIndexVector(iStartNew);
940  index_type iEndVec = iRoundEndIndexVector(iEndNew);
941  const index_type iSizeVec = iEndVec - iStartVec;
942 
943  if (iSizeVec > iCapCurr) {
944  FreeMem();
945 
946  pData = GradientAllocator<Data>::allocate_aligned(sizeof(vector_type), 1u, sizeof(vector_type) * iSizeVec);
947 
948  pData->iCapacityVec = iSizeVec;
949  }
950 
951  GRADIENT_ASSERT(((char*)(pData->rgArrayVec) - (char*)0) % sizeof(vector_type) == 0);
952 
953  if (pData == pNullData()) {
954  GRADIENT_ASSERT(iSizeVec == 0);
955 
956  return;
957  }
958 
959  if (eFlags == RESERVE) {
960  iStartNew = iEndNew = iStartVec = iEndVec = 0;
961  }
962 
963  pData->iStart = iStartNew;
964  pData->iEnd = iEndNew;
965  pData->iStartVec = iStartVec;
966  pData->iEndVec = iEndVec;
967  }
index_type iGetCapacityVector() const
Definition: gradient.h:874
RangeVectorBase< T, 0 >::vector_type vector_type
Definition: gradient.h:649
integer index_type
Definition: gradient.h:104
static index_type iRoundEndIndexVector(index_type iEnd)
Definition: gradient.h:368
static index_type iRoundStartIndexVector(index_type iStart)
Definition: gradient.h:364
static T * allocate_aligned(size_type alignment, size_t n, size_type extra_bytes=0u)
Definition: gradient.h:198
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
static Data * pNullData()
Definition: gradient.h:976

Here is the call graph for this function:

template<typename T >
void grad::RangeVector< T, 0 >::Reset ( void  )
inline

Definition at line 754 of file gradient.h.

References grad::array_fill(), and GRADIENT_ASSERT.

Referenced by ResizePreserve().

754  {
755  GRADIENT_ASSERT(bInvariant());
756  // Reset the data but preserve memory and iStart
757  array_fill(beginVec(), endVec(), RangeVectorTraits<vector_type>::Zero());
758 
759  GRADIENT_ASSERT(bInvariant());
760  }
vector_type * beginVec()
Definition: gradient.h:921
vector_type * endVec()
Definition: gradient.h:925
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
void array_fill(T *first, T *const last, const T &val)
Definition: gradient.h:309

Here is the call graph for this function:

template<typename T >
void grad::RangeVector< T, 0 >::ResizePreserve ( index_type  iStartNew,
index_type  iEndNew 
)
inline

Definition at line 723 of file gradient.h.

References grad::array_copy(), grad::array_fill(), beginVec(), GRADIENT_ASSERT, grad::RangeVector< T, N_SIZE >::iEndVec, grad::RangeVector< T, N_SIZE >::iGetEndIndexVector(), iGetEndIndexVector(), grad::RangeVector< T, N_SIZE >::iGetStartIndexVector(), iGetStartIndexVector(), grad::RangeVectorBase< T, N_SIZE >::iRoundEndIndexVector(), grad::RangeVectorBase< T, N_SIZE >::iRoundStartIndexVector(), pData, ReserveMem(), and Reset().

723  {
724  GRADIENT_ASSERT(bInvariant());
725  const index_type iStartNewVec = iRoundStartIndexVector(iStartNew);
726  const index_type iEndNewVec = iRoundEndIndexVector(iEndNew);
727 
728  if (iStartNewVec == iGetStartIndexVector() && iEndNewVec - iStartNewVec <= iGetCapacityVector()) {
729  const index_type iEndCurrVec = iGetEndIndexVector();
730 
731  ReserveMem(iStartNew, iEndNew, RESIZE);
732 
733  GRADIENT_ASSERT(iEndCurrVec <= pData->iEndVec);
734 
735  array_fill(beginVec() + iEndCurrVec, endVec(), RangeVectorTraits<vector_type>::Zero());
736  }
737  else {
738  RangeVector<T, 0> oTmpVec;
739  oTmpVec.ReserveMem(iStartNew, iEndNew, RESIZE);
740  oTmpVec.Reset();
741  const index_type iComStartVec = std::max(iGetStartIndexVector(), oTmpVec.iGetStartIndexVector());
742  const index_type iComEndVec = std::min(iGetEndIndexVector(), oTmpVec.iGetEndIndexVector());
743 
744  array_copy(beginVec() + iComStartVec - iGetStartIndexVector(),
745  beginVec() + iComEndVec - iGetStartIndexVector(),
746  oTmpVec.beginVec() + iComStartVec - oTmpVec.iGetStartIndexVector());
747 
748  std::swap(pData, oTmpVec.pData);
749  }
750 
751  GRADIENT_ASSERT(bInvariant());
752  }
index_type iGetCapacityVector() const
Definition: gradient.h:874
void ReserveMem(index_type iStartNew, index_type iEndNew, MemFlags eFlags=RESIZE)
Definition: gradient.h:937
integer index_type
Definition: gradient.h:104
index_type iGetEndIndexVector() const
Definition: gradient.h:799
static index_type iRoundEndIndexVector(index_type iEnd)
Definition: gradient.h:368
static index_type iRoundStartIndexVector(index_type iStart)
Definition: gradient.h:364
vector_type * beginVec()
Definition: gradient.h:921
vector_type * endVec()
Definition: gradient.h:925
index_type iGetStartIndexVector() const
Definition: gradient.h:795
T * array_copy(const T *first, const T *const last, T *result)
Definition: gradient.h:316
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74
void array_fill(T *first, T *const last, const T &val)
Definition: gradient.h:309

Here is the call graph for this function:

template<typename T >
void grad::RangeVector< T, 0 >::ResizeReset ( index_type  iStartNew,
index_type  iEndNew,
const scalar_type dVal 
)
inline

Definition at line 714 of file gradient.h.

References GRADIENT_ASSERT, and grad::RangeVector< T, N_SIZE >::Initialize().

714  {
715  GRADIENT_ASSERT(bInvariant());
716 
717  ReserveMem(iStartNew, iEndNew, RESIZE);
718  Initialize(iStartNew, iEndNew, dVal);
719 
720  GRADIENT_ASSERT(bInvariant());
721  }
void ReserveMem(index_type iStartNew, index_type iEndNew, MemFlags eFlags=RESIZE)
Definition: gradient.h:937
void Initialize(index_type iStart, index_type iEnd, const scalar_type &dVal)
Definition: gradient.h:890
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74

Here is the call graph for this function:

template<typename T >
void grad::RangeVector< T, 0 >::SetValue ( index_type  i,
const scalar_type d 
)
inline

Definition at line 823 of file gradient.h.

References GRADIENT_ASSERT, grad::RangeVector< T, N_SIZE >::iGetEndIndex(), grad::RangeVector< T, N_SIZE >::iGetMaxSize(), grad::RangeVector< T, N_SIZE >::iGetStartIndex(), grad::RangeVector< T, N_SIZE >::iGetStartIndexVector(), and grad::RangeVector< T, N_SIZE >::iVectorSize.

823  {
824  GRADIENT_ASSERT(i >= 0);
827 
828  begin()[i - iGetStartIndexVector() * iVectorSize] = d;
829  }
index_type iGetEndIndex() const
Definition: gradient.h:791
index_type iGetStartIndex() const
Definition: gradient.h:787
scalar_type * begin()
Definition: gradient.h:905
static const index_type iVectorSize
Definition: gradient.h:647
static index_type iGetMaxSize()
Definition: gradient.h:811
index_type iGetStartIndexVector() const
Definition: gradient.h:795
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74

Here is the call graph for this function:

template<typename T >
void grad::RangeVector< T, 0 >::SetVectorValue ( index_type  i,
const vector_type d 
)
inline

Definition at line 840 of file gradient.h.

References GRADIENT_ASSERT, grad::RangeVector< T, N_SIZE >::iGetEndIndexVector(), grad::RangeVector< T, N_SIZE >::iGetStartIndexVector(), and grad::RangeVector< T, N_SIZE >::iMaxSizeVector.

840  {
841  GRADIENT_ASSERT(i >= 0);
844 
845  beginVec()[i - iGetStartIndexVector()] = d;
846  }
index_type iGetEndIndexVector() const
Definition: gradient.h:799
static const index_type iMaxSizeVector
Definition: gradient.h:653
vector_type * beginVec()
Definition: gradient.h:921
index_type iGetStartIndexVector() const
Definition: gradient.h:795
#define GRADIENT_ASSERT(expr)
Definition: gradient.h:74

Here is the call graph for this function:

Member Data Documentation

template<typename T >
const index_type grad::RangeVector< T, 0 >::iMaxSize = IntegerTypeTraits<index_type>::iMaxValue / sizeof(scalar_type)
static

Definition at line 651 of file gradient.h.

template<typename T >
const index_type grad::RangeVector< T, 0 >::iMaxSizeVector = iMaxSize / iVectorSize
static

Definition at line 653 of file gradient.h.

template<typename T >
const index_type grad::RangeVector< T, 0 >::iVectorSize = RangeVectorBase<T, 0>::iVectorSize
static

Definition at line 647 of file gradient.h.

template<typename T >
Data* grad::RangeVector< T, 0 >::pData
private

Definition at line 1011 of file gradient.h.

Referenced by ResizePreserve().

template<typename T >
const RangeVector< T, 0 >::Data grad::RangeVector< T, 0 >::sNullData = {0}
staticprivate

Definition at line 1012 of file gradient.h.


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