SNAP Library 6.0, Developer Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
TGLib_OLD::TVecPool< TVal > Class Template Reference

#include <ds.h>

Collaboration diagram for TGLib_OLD::TVecPool< TVal >:

Public Types

typedef TPt< TVecPool< TVal > > PVecPool
 
typedef TVec< TVal > TValV
 

Public Member Functions

 TVecPool (const ::TSize &ExpectVals=0, const ::TSize &_GrowBy=1000000, const bool &_FastCopy=false, const TVal &_EmptyVal=TVal())
 
 TVecPool (const TVecPool &Pool)
 
 TVecPool (TSIn &SIn)
 
 ~TVecPool ()
 
void Save (TSOut &SOut) const
 
TVecPooloperator= (const TVecPool &Pool)
 
::TSize GetVals () const
 
::TSize GetVecs () const
 
bool IsVId (const int &VId) const
 
::TSize Reserved () const
 
void Reserve (const ::TSize &MxVals)
 
const TVal & GetEmptyVal () const
 
void SetEmptyVal (const TVal &_EmptyVal)
 
::TSize GetMemUsed () const
 
int AddV (const TValV &ValV)
 
int AddEmptyV (const int &ValVLen)
 
uint GetVLen (const int &VId) const
 
TVal * GetValVPt (const int &VId) const
 
void GetV (const int &VId, TValV &ValV) const
 
void PutV (const int &VId, const TValV &ValV)
 
void CompactPool (const TVal &DelVal)
 
void ShuffleAll (TRnd &Rnd=TInt::Rnd)
 
void Clr (bool DoDel=true)
 
void PutAll (const TVal &Val)
 

Static Public Member Functions

static PVecPool New (const ::TSize &ExpectVals=0, const ::TSize &GrowBy=1000000, const bool &FastCopy=false)
 
static PVecPool Load (TSIn &SIn)
 
static PVecPool Load (const TStr &FNm)
 

Private Member Functions

void Resize (const ::TSize &_MxVals)
 

Private Attributes

TCRef CRef
 
TBool FastCopy
 
::TSize GrowBy
 
::TSize MxVals
 
::TSize Vals
 
TVal EmptyVal
 
TVal * ValBf
 
TVec< ::TSizeIdToOffV
 

Friends

class TPt< TVecPool< TVal > >
 

Detailed Description

template<class TVal>
class TGLib_OLD::TVecPool< TVal >

Definition at line 1939 of file ds.h.

Member Typedef Documentation

template<class TVal >
typedef TPt<TVecPool<TVal> > TGLib_OLD::TVecPool< TVal >::PVecPool

Definition at line 1941 of file ds.h.

template<class TVal >
typedef TVec<TVal> TGLib_OLD::TVecPool< TVal >::TValV

Definition at line 1942 of file ds.h.

Constructor & Destructor Documentation

template<class TVal >
TVecPool< TVal >::TVecPool ( const ::TSize ExpectVals = 0,
const ::TSize _GrowBy = 1000000,
const bool &  _FastCopy = false,
const TVal &  _EmptyVal = TVal() 
)

Definition at line 2038 of file ds.h.

References TVec< TVal, TSizeTy >::Add(), and TGLib_OLD::TVecPool< TVal >::Resize().

Referenced by TGLib_OLD::TVecPool< TVal >::Load(), and TGLib_OLD::TVecPool< TVal >::New().

2038  :
2039  GrowBy(_GrowBy), MxVals(0), Vals(0), EmptyVal(_EmptyVal), ValBf(NULL) {
2040  IdToOffV.Add(0);
2041  Resize(ExpectVals);
2042 }
::TSize Vals
Definition: ds.h:1946
TVec< ::TSize > IdToOffV
Definition: ds.h:1949
::TSize GrowBy
Definition: ds.h:1946
::TSize MxVals
Definition: ds.h:1946
void Resize(const ::TSize &_MxVals)
Definition: ds.h:2011
TVal * ValBf
Definition: ds.h:1948
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TVal >
TVecPool< TVal >::TVecPool ( const TVecPool< TVal > &  Pool)

Definition at line 2045 of file ds.h.

References FailR, TStr::Fmt(), IAssert, TGLib_OLD::TVecPool< TVal >::MxVals, and TGLib_OLD::TVecPool< TVal >::ValBf.

2045  :
2046  FastCopy(Pool.FastCopy), GrowBy(Pool.GrowBy),
2047  MxVals(Pool.MxVals), Vals(Pool.Vals), EmptyVal(Pool.EmptyVal), IdToOffV(Pool.IdToOffV) {
2048  try { ValBf = new TVal [MxVals]; }
2049  catch (std::exception Ex) { FailR(TStr::Fmt("TVecPool::TVecPool: %s, MxVals: %d", Ex.what(), MxVals).CStr()); }
2050  IAssert(ValBf != NULL);
2051  if (FastCopy) {
2052  memcpy(ValBf, Pool.ValBf, MxVals*sizeof(TVal)); }
2053  else {
2054  for (TSize ValN = 0; ValN < MxVals; ValN++){ ValBf[ValN] = Pool.ValBf[ValN]; } }
2055 }
#define IAssert(Cond)
Definition: bd.h:262
::TSize Vals
Definition: ds.h:1946
TVal * ValBf
Definition: ds.h:1682
TVec< ::TSize > IdToOffV
Definition: ds.h:1949
::TSize GrowBy
Definition: ds.h:1946
TSize GrowBy
Definition: ds.h:1680
TVal EmptyVal
Definition: ds.h:1681
::TSize MxVals
Definition: ds.h:1946
size_t TSize
Definition: bd.h:58
#define FailR(Reason)
Definition: bd.h:240
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TBool FastCopy
Definition: ds.h:1679
TVal * ValBf
Definition: ds.h:1948
TVec< uint64, int > IdToOffV
Definition: ds.h:1683
TBool FastCopy
Definition: ds.h:1945
TSize Vals
Definition: ds.h:1680
TSize MxVals
Definition: ds.h:1680

Here is the call graph for this function:

template<class TVal >
TVecPool< TVal >::TVecPool ( TSIn SIn)

Definition at line 2058 of file ds.h.

References TVec< TVal, TSizeTy >::Gen(), IAssert, TSIn::Load(), TGLib_OLD::TVecPool< TVal >::MxVals, TSizeMx, and TGLib_OLD::TVecPool< TVal >::Vals.

2058  :
2059  FastCopy(SIn) {
2060  uint64 _GrowBy, _MxVals, _Vals;
2061  SIn.Load(_GrowBy); SIn.Load(_MxVals); SIn.Load(_Vals);
2062  IAssert(_GrowBy<TSizeMx && _MxVals<TSizeMx && _Vals<TSizeMx);
2063  GrowBy=TSize(_GrowBy); MxVals=TSize(_Vals); Vals=TSize(_Vals); //note MxVals==Vals
2064  EmptyVal = TVal(SIn);
2065  if (MxVals==0) { ValBf = NULL; } else { ValBf = new TVal [MxVals]; }
2066  for (TSize ValN = 0; ValN < Vals; ValN++) { ValBf[ValN] = TVal(SIn); }
2067  { TInt MxVals(SIn), Vals(SIn);
2068  IdToOffV.Gen(Vals);
2069  for (int ValN = 0; ValN < Vals; ValN++) {
2070  uint64 Offset; SIn.Load(Offset); IAssert(Offset < TSizeMx);
2071  IdToOffV[ValN]=TSize(Offset);
2072  } }
2073 }
#define IAssert(Cond)
Definition: bd.h:262
::TSize Vals
Definition: ds.h:1946
TVec< ::TSize > IdToOffV
Definition: ds.h:1949
::TSize GrowBy
Definition: ds.h:1946
::TSize MxVals
Definition: ds.h:1946
unsigned long long uint64
Definition: bd.h:38
void Load(bool &Bool)
Definition: fl.h:84
#define TSizeMx
Definition: bd.h:59
size_t TSize
Definition: bd.h:58
Definition: dt.h:1137
TVal * ValBf
Definition: ds.h:1948
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523
TBool FastCopy
Definition: ds.h:1945

Here is the call graph for this function:

template<class TVal >
TGLib_OLD::TVecPool< TVal >::~TVecPool ( )
inline

Definition at line 1956 of file ds.h.

References TGLib_OLD::TVecPool< TVal >::ValBf.

1956 { if (ValBf != NULL) { delete [] ValBf; } ValBf=NULL; }
TVal * ValBf
Definition: ds.h:1948

Member Function Documentation

template<class TVal >
int TVecPool< TVal >::AddEmptyV ( const int &  ValVLen)

Definition at line 2120 of file ds.h.

References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::Len(), and MAX.

2120  {
2121  if (ValVLen==0){return 0;}
2122  if (MxVals < Vals+ValVLen){Resize(Vals+MAX(TSize(ValVLen), GrowBy)); }
2123  Vals+=ValVLen; IdToOffV.Add(Vals);
2124  return IdToOffV.Len()-1;
2125 }
::TSize Vals
Definition: ds.h:1946
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TVec< ::TSize > IdToOffV
Definition: ds.h:1949
::TSize GrowBy
Definition: ds.h:1946
::TSize MxVals
Definition: ds.h:1946
void Resize(const ::TSize &_MxVals)
Definition: ds.h:2011
size_t TSize
Definition: bd.h:58
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
#define MAX(a, b)
Definition: bd.h:350

Here is the call graph for this function:

template<class TVal >
int TVecPool< TVal >::AddV ( const TValV ValV)

Definition at line 2109 of file ds.h.

References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::BegI(), TVec< TVal, TSizeTy >::Len(), and MAX.

2109  {
2110  const ::TSize ValVLen = ValV.Len();
2111  if (ValVLen == 0) { return 0; }
2112  if (MxVals < Vals+ValVLen) { Resize(Vals+MAX(ValVLen, GrowBy)); }
2113  if (FastCopy) { memcpy(ValBf+Vals, ValV.BegI(), sizeof(TVal)*ValV.Len()); }
2114  else { for (uint ValN=0; ValN < ValVLen; ValN++) { ValBf[Vals+ValN]=ValV[ValN]; } }
2115  Vals+=ValVLen; IdToOffV.Add(Vals);
2116  return IdToOffV.Len()-1;
2117 }
::TSize Vals
Definition: ds.h:1946
unsigned int uint
Definition: bd.h:11
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TVec< ::TSize > IdToOffV
Definition: ds.h:1949
::TSize GrowBy
Definition: ds.h:1946
::TSize MxVals
Definition: ds.h:1946
void Resize(const ::TSize &_MxVals)
Definition: ds.h:2011
size_t TSize
Definition: bd.h:58
TVal * ValBf
Definition: ds.h:1948
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
#define MAX(a, b)
Definition: bd.h:350
TBool FastCopy
Definition: ds.h:1945

Here is the call graph for this function:

template<class TVal >
void TGLib_OLD::TVecPool< TVal >::Clr ( bool  DoDel = true)
inline

Definition at line 1999 of file ds.h.

References TVec< TVal, TSizeTy >::Clr(), TGLib_OLD::TVecPool< TVal >::PutAll(), and TGLib_OLD::TVecPool< TVal >::ValBf.

1999  {
2000  IdToOffV.Clr(DoDel); MxVals=0; Vals=0;
2001  if (DoDel && ValBf!=NULL) { delete [] ValBf; ValBf=NULL;}
2002  if (! DoDel) { PutAll(EmptyVal); }
2003  }
::TSize Vals
Definition: ds.h:1946
TVec< ::TSize > IdToOffV
Definition: ds.h:1949
void PutAll(const TVal &Val)
Definition: ds.h:2004
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:1022
::TSize MxVals
Definition: ds.h:1946
TVal * ValBf
Definition: ds.h:1948

Here is the call graph for this function:

template<class TVal >
void TVecPool< TVal >::CompactPool ( const TVal &  DelVal)

Definition at line 2130 of file ds.h.

References TVec< TVal, TSizeTy >::Last(), and TVec< TVal, TSizeTy >::Len().

2130  {
2131  ::TSize TotalDel=0, NDel=0;
2132  // printf("Compacting %d vectors\n", IdToOffV.Len());
2133  for (int vid = 1; vid < IdToOffV.Len(); vid++) {
2134  // if (vid % 10000000 == 0) { printf(" %dm", vid/1000000); fflush(stdout); }
2135  const uint Len = GetVLen(vid);
2136  TVal* ValV = GetValVPt(vid);
2137  if (TotalDel > 0) { IdToOffV[vid-1] -= TotalDel; } // update end of vector
2138  if (Len == 0) { continue; }
2139  NDel = 0;
2140  for (TVal* v = ValV; v < ValV+Len-NDel; v++) {
2141  if (*v == DelVal) {
2142  TVal* Beg = v;
2143  while (*v == DelVal && v < ValV+Len) { v++; NDel++; }
2144  memcpy(Beg, v, sizeof(TVal)*int(Len - ::TSize(v - ValV)));
2145  v -= NDel;
2146  }
2147  }
2148  memcpy(ValV-TotalDel, ValV, sizeof(TVal)*Len); // move data
2149  TotalDel += NDel;
2150  }
2151  IdToOffV.Last() -= TotalDel;
2152  for (::TSize i = Vals-TotalDel; i < Vals; i++) { ValBf[i] = EmptyVal; }
2153  Vals -= TotalDel;
2154  // printf(" deleted %llu elements from the pool\n", TotalDel);
2155 }
::TSize Vals
Definition: ds.h:1946
unsigned int uint
Definition: bd.h:11
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TVec< ::TSize > IdToOffV
Definition: ds.h:1949
uint GetVLen(const int &VId) const
Definition: ds.h:1977
size_t TSize
Definition: bd.h:58
const TVal & Last() const
Returns a reference to the last element of the vector.
Definition: ds.h:579
TVal * ValBf
Definition: ds.h:1948
TVal * GetValVPt(const int &VId) const
Definition: ds.h:1980

Here is the call graph for this function:

template<class TVal >
const TVal& TGLib_OLD::TVecPool< TVal >::GetEmptyVal ( ) const
inline

Definition at line 1970 of file ds.h.

References TGLib_OLD::TVecPool< TVal >::EmptyVal.

1970 { return EmptyVal; }
template<class TVal >
::TSize TGLib_OLD::TVecPool< TVal >::GetMemUsed ( ) const
inline

Definition at line 1972 of file ds.h.

1972  {
1973  return sizeof(TCRef)+sizeof(TBool)+3*sizeof(TSize)+sizeof(TVal*)+MxVals*sizeof(TVal);}
Definition: bd.h:440
::TSize MxVals
Definition: ds.h:1946
size_t TSize
Definition: bd.h:58
Definition: dt.h:974
template<class TVal >
void TGLib_OLD::TVecPool< TVal >::GetV ( const int &  VId,
TValV ValV 
) const
inline

Definition at line 1983 of file ds.h.

References TVec< TVal, TSizeTy >::Clr(), TVec< TVal, TSizeTy >::GenExt(), TGLib_OLD::TVecPool< TVal >::GetValVPt(), and TGLib_OLD::TVecPool< TVal >::GetVLen().

1983  {
1984  if (GetVLen(VId)==0){ValV.Clr();}
1985  else { ValV.GenExt(GetValVPt(VId), GetVLen(VId)); } }
uint GetVLen(const int &VId) const
Definition: ds.h:1977
TVal * GetValVPt(const int &VId) const
Definition: ds.h:1980

Here is the call graph for this function:

template<class TVal >
::TSize TGLib_OLD::TVecPool< TVal >::GetVals ( ) const
inline

Definition at line 1965 of file ds.h.

References TGLib_OLD::TVecPool< TVal >::Vals.

1965 { return Vals; }
::TSize Vals
Definition: ds.h:1946
template<class TVal >
TVal* TGLib_OLD::TVecPool< TVal >::GetValVPt ( const int &  VId) const
inline

Definition at line 1980 of file ds.h.

References TGLib_OLD::TVecPool< TVal >::EmptyVal, and TGLib_OLD::TVecPool< TVal >::GetVLen().

Referenced by TGLib_OLD::TVecPool< TVal >::GetV(), and TGLib_OLD::TVecPool< TVal >::PutV().

1980  {
1981  if (GetVLen(VId)==0){return (TVal*)&EmptyVal;}
1982  else {return ValBf+IdToOffV[VId-1];}}
TVec< ::TSize > IdToOffV
Definition: ds.h:1949
uint GetVLen(const int &VId) const
Definition: ds.h:1977
TVal * ValBf
Definition: ds.h:1948

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TVal >
::TSize TGLib_OLD::TVecPool< TVal >::GetVecs ( ) const
inline

Definition at line 1966 of file ds.h.

References TVec< TVal, TSizeTy >::Len().

1966 { return IdToOffV.Len(); }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TVec< ::TSize > IdToOffV
Definition: ds.h:1949

Here is the call graph for this function:

template<class TVal >
uint TGLib_OLD::TVecPool< TVal >::GetVLen ( const int &  VId) const
inline

Definition at line 1977 of file ds.h.

Referenced by TGLib_OLD::TVecPool< TVal >::GetV(), TGLib_OLD::TVecPool< TVal >::GetValVPt(), and TGLib_OLD::TVecPool< TVal >::PutV().

1977  {
1978  if (VId==0){return 0;}
1979  else {return uint(IdToOffV[VId]-IdToOffV[VId-1]);}}
unsigned int uint
Definition: bd.h:11
TVec< ::TSize > IdToOffV
Definition: ds.h:1949

Here is the caller graph for this function:

template<class TVal >
bool TGLib_OLD::TVecPool< TVal >::IsVId ( const int &  VId) const
inline

Definition at line 1967 of file ds.h.

References TVec< TVal, TSizeTy >::Len().

Referenced by TGLib_OLD::TVecPool< TVal >::PutV().

1967 { return (0 <= VId) && (VId < IdToOffV.Len()); }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TVec< ::TSize > IdToOffV
Definition: ds.h:1949

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TVal >
static PVecPool TGLib_OLD::TVecPool< TVal >::Load ( TSIn SIn)
inlinestatic

Definition at line 1959 of file ds.h.

References TGLib_OLD::TVecPool< TVal >::TVecPool().

1959 { return new TVecPool(SIn); }
TVecPool(const ::TSize &ExpectVals=0, const ::TSize &_GrowBy=1000000, const bool &_FastCopy=false, const TVal &_EmptyVal=TVal())
Definition: ds.h:2038

Here is the call graph for this function:

template<class TVal >
static PVecPool TGLib_OLD::TVecPool< TVal >::Load ( const TStr FNm)
inlinestatic

Definition at line 1960 of file ds.h.

References TGLib_OLD::TVecPool< TVal >::Load().

Referenced by TGLib_OLD::TVecPool< TVal >::Load().

1960 { TFIn FIn(FNm); return Load(FIn); }
Definition: fl.h:275
static PVecPool Load(TSIn &SIn)
Definition: ds.h:1959

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TVal >
static PVecPool TGLib_OLD::TVecPool< TVal >::New ( const ::TSize ExpectVals = 0,
const ::TSize GrowBy = 1000000,
const bool &  FastCopy = false 
)
inlinestatic

Definition at line 1957 of file ds.h.

References TGLib_OLD::TVecPool< TVal >::TVecPool().

1957  {
1958  return new TVecPool(ExpectVals, GrowBy, FastCopy); }
::TSize GrowBy
Definition: ds.h:1946
TVecPool(const ::TSize &ExpectVals=0, const ::TSize &_GrowBy=1000000, const bool &_FastCopy=false, const TVal &_EmptyVal=TVal())
Definition: ds.h:2038
TBool FastCopy
Definition: ds.h:1945

Here is the call graph for this function:

template<class TVal >
TVecPool< TVal > & TVecPool< TVal >::operator= ( const TVecPool< TVal > &  Pool)

Definition at line 2089 of file ds.h.

References TGLib_OLD::TVecPool< TVal >::EmptyVal, FailR, TGLib_OLD::TVecPool< TVal >::FastCopy, TStr::Fmt(), TGLib_OLD::TVecPool< TVal >::GrowBy, IAssert, TGLib_OLD::TVecPool< TVal >::IdToOffV, TGLib_OLD::TVecPool< TVal >::MxVals, TGLib_OLD::TVecPool< TVal >::ValBf, and TGLib_OLD::TVecPool< TVal >::Vals.

2089  {
2090  if (this!=&Pool) {
2091  FastCopy = Pool.FastCopy;
2092  GrowBy = Pool.GrowBy;
2093  MxVals = Pool.MxVals;
2094  Vals = Pool.Vals;
2095  EmptyVal = Pool.EmptyVal;
2096  IdToOffV=Pool.IdToOffV;
2097  try { ValBf = new TVal [MxVals]; }
2098  catch (std::exception Ex) { FailR(TStr::Fmt("TVec::operator= : %s, MxVals: %d", Ex.what(), MxVals).CStr()); }
2099  IAssert(ValBf != NULL);
2100  if (FastCopy) {
2101  memcpy(ValBf, Pool.ValBf, Vals*sizeof(TVal)); }
2102  else {
2103  for (uint64 ValN = 0; ValN < Vals; ValN++){ ValBf[ValN] = Pool.ValBf[ValN]; } }
2104  }
2105  return *this;
2106 }
#define IAssert(Cond)
Definition: bd.h:262
::TSize Vals
Definition: ds.h:1946
TVal * ValBf
Definition: ds.h:1682
TVec< ::TSize > IdToOffV
Definition: ds.h:1949
::TSize GrowBy
Definition: ds.h:1946
TSize GrowBy
Definition: ds.h:1680
TVal EmptyVal
Definition: ds.h:1681
::TSize MxVals
Definition: ds.h:1946
unsigned long long uint64
Definition: bd.h:38
#define FailR(Reason)
Definition: bd.h:240
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TBool FastCopy
Definition: ds.h:1679
TVal * ValBf
Definition: ds.h:1948
TVec< uint64, int > IdToOffV
Definition: ds.h:1683
TBool FastCopy
Definition: ds.h:1945
TSize Vals
Definition: ds.h:1680
TSize MxVals
Definition: ds.h:1680

Here is the call graph for this function:

template<class TVal >
void TGLib_OLD::TVecPool< TVal >::PutAll ( const TVal &  Val)
inline

Definition at line 2004 of file ds.h.

References TGLib_OLD::TVecPool< TVal >::MxVals.

Referenced by TGLib_OLD::TVecPool< TVal >::Clr().

2004  {
2005  for (TSize ValN = 0; ValN < MxVals; ValN++) { ValBf[ValN]=Val; } }
::TSize MxVals
Definition: ds.h:1946
size_t TSize
Definition: bd.h:58
TVal * ValBf
Definition: ds.h:1948

Here is the caller graph for this function:

template<class TVal >
void TGLib_OLD::TVecPool< TVal >::PutV ( const int &  VId,
const TValV ValV 
)
inline

Definition at line 1986 of file ds.h.

References TVec< TVal, TSizeTy >::BegI(), TGLib_OLD::TVecPool< TVal >::GetValVPt(), TGLib_OLD::TVecPool< TVal >::GetVLen(), IAssert, TGLib_OLD::TVecPool< TVal >::IsVId(), and TVec< TVal, TSizeTy >::Len().

1986  {
1987  IAssert(IsVId(VId) && GetVLen(VId) == ValV.Len());
1988  if (FastCopy) {
1989  memcpy(GetValVPt(VId), ValV.BegI(), sizeof(TVal)*ValV.Len()); }
1990  else { TVal* ValPt = GetValVPt(VId);
1991  for (uint ValN=0; ValN < uint(ValV.Len()); ValN++, ValPt++) { *ValPt=ValV[ValN]; }
1992  }
1993  }
#define IAssert(Cond)
Definition: bd.h:262
unsigned int uint
Definition: bd.h:11
bool IsVId(const int &VId) const
Definition: ds.h:1967
uint GetVLen(const int &VId) const
Definition: ds.h:1977
TBool FastCopy
Definition: ds.h:1945
TVal * GetValVPt(const int &VId) const
Definition: ds.h:1980

Here is the call graph for this function:

template<class TVal >
void TGLib_OLD::TVecPool< TVal >::Reserve ( const ::TSize MxVals)
inline

Definition at line 1969 of file ds.h.

References TGLib_OLD::TVecPool< TVal >::Resize().

1969 { Resize(MxVals); }
::TSize MxVals
Definition: ds.h:1946
void Resize(const ::TSize &_MxVals)
Definition: ds.h:2011

Here is the call graph for this function:

template<class TVal >
::TSize TGLib_OLD::TVecPool< TVal >::Reserved ( ) const
inline

Definition at line 1968 of file ds.h.

References TGLib_OLD::TVecPool< TVal >::MxVals.

1968 { return MxVals; }
::TSize MxVals
Definition: ds.h:1946
template<class TVal >
void TVecPool< TVal >::Resize ( const ::TSize _MxVals)
private

Definition at line 2011 of file ds.h.

References FailR, TStr::Fmt(), and IAssert.

Referenced by TGLib_OLD::TVecPool< TVal >::Reserve(), and TGLib_OLD::TVecPool< TVal >::TVecPool().

2011  {
2012  if (_MxVals <= MxVals){ return; } else { MxVals = _MxVals; }
2013  if (ValBf == NULL) {
2014  try { ValBf = new TVal [MxVals]; }
2015  catch (std::exception Ex) {
2016  FailR(TStr::Fmt("TVecPool::Resize 1: %s, MxVals: %d. [Program failed to allocate more memory. Solution: Get a bigger machine and a 64-bit compiler.]", Ex.what(), _MxVals).CStr()); }
2017  IAssert(ValBf != NULL);
2018  if (EmptyVal != TVal()) { PutAll(EmptyVal); }
2019  } else {
2020  // printf("*** Resize vector pool: %llu -> %llu\n", uint64(Vals), uint64(MxVals));
2021  TVal* NewValBf = NULL;
2022  try { NewValBf = new TVal [MxVals]; }
2023  catch (std::exception Ex) { FailR(TStr::Fmt("TVecPool::Resize 2: %s, MxVals: %d. [Program failed to allocate more memory. Solution: Get a bigger machine and a 64-bit compiler.]", Ex.what(), _MxVals).CStr()); }
2024  IAssert(NewValBf != NULL);
2025  if (FastCopy) {
2026  memcpy(NewValBf, ValBf, Vals*sizeof(TVal)); }
2027  else {
2028  for (TSize ValN = 0; ValN < Vals; ValN++){ NewValBf[ValN] = ValBf[ValN]; } }
2029  if (EmptyVal != TVal()) { // init empty values
2030  for (TSize ValN = Vals; ValN < MxVals; ValN++) { NewValBf[ValN] = EmptyVal; }
2031  }
2032  delete [] ValBf;
2033  ValBf = NewValBf;
2034  }
2035 }
#define IAssert(Cond)
Definition: bd.h:262
::TSize Vals
Definition: ds.h:1946
void PutAll(const TVal &Val)
Definition: ds.h:2004
::TSize MxVals
Definition: ds.h:1946
size_t TSize
Definition: bd.h:58
#define FailR(Reason)
Definition: bd.h:240
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TVal * ValBf
Definition: ds.h:1948
TBool FastCopy
Definition: ds.h:1945

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TVal >
void TVecPool< TVal >::Save ( TSOut SOut) const

Definition at line 2076 of file ds.h.

References TVec< TVal, TSizeTy >::Len(), and TSOut::Save().

2076  {
2077  SOut.Save(FastCopy);
2078  uint64 _GrowBy=GrowBy, _MxVals=MxVals, _Vals=Vals;
2079  SOut.Save(_GrowBy); SOut.Save(_MxVals); SOut.Save(_Vals);
2080  SOut.Save(EmptyVal);
2081  for (TSize ValN = 0; ValN < Vals; ValN++) { ValBf[ValN].Save(SOut); }
2082  { SOut.Save(IdToOffV.Len()); SOut.Save(IdToOffV.Len());
2083  for (int ValN = 0; ValN < IdToOffV.Len(); ValN++) {
2084  const uint64 Offset=IdToOffV[ValN]; SOut.Save(Offset);
2085  } }
2086 }
::TSize Vals
Definition: ds.h:1946
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TVec< ::TSize > IdToOffV
Definition: ds.h:1949
::TSize GrowBy
Definition: ds.h:1946
::TSize MxVals
Definition: ds.h:1946
unsigned long long uint64
Definition: bd.h:38
size_t TSize
Definition: bd.h:58
void Save(const bool &Bool)
Definition: fl.h:173
TVal * ValBf
Definition: ds.h:1948
TBool FastCopy
Definition: ds.h:1945

Here is the call graph for this function:

template<class TVal >
void TGLib_OLD::TVecPool< TVal >::SetEmptyVal ( const TVal &  _EmptyVal)
inline

Definition at line 1971 of file ds.h.

1971 { EmptyVal = _EmptyVal; }
template<class TVal >
void TVecPool< TVal >::ShuffleAll ( TRnd Rnd = TInt::Rnd)

Definition at line 2159 of file ds.h.

References TRnd::GetUniDevInt().

2159  {
2160  for (::TSize n = Vals-1; n > 0; n--) {
2161  const ::TSize k = ::TSize(((uint64(Rnd.GetUniDevInt())<<32) | uint64(Rnd.GetUniDevInt())) % (n+1));
2162  const TVal Tmp = ValBf[n];
2163  ValBf[n] = ValBf[k];
2164  ValBf[k] = Tmp;
2165  }
2166 }
::TSize Vals
Definition: ds.h:1946
unsigned long long uint64
Definition: bd.h:38
size_t TSize
Definition: bd.h:58
TVal * ValBf
Definition: ds.h:1948
int GetUniDevInt(const int &Range=0)
Definition: dt.cpp:39

Here is the call graph for this function:

Friends And Related Function Documentation

template<class TVal >
friend class TPt< TVecPool< TVal > >
friend

Definition at line 2007 of file ds.h.

Member Data Documentation

template<class TVal >
TCRef TGLib_OLD::TVecPool< TVal >::CRef
private

Definition at line 1944 of file ds.h.

template<class TVal >
TVal TGLib_OLD::TVecPool< TVal >::EmptyVal
private
template<class TVal >
TBool TGLib_OLD::TVecPool< TVal >::FastCopy
private

Definition at line 1945 of file ds.h.

Referenced by TGLib_OLD::TVecPool< TVal >::operator=().

template<class TVal >
::TSize TGLib_OLD::TVecPool< TVal >::GrowBy
private

Definition at line 1946 of file ds.h.

Referenced by TGLib_OLD::TVecPool< TVal >::operator=().

template<class TVal >
TVec< ::TSize> TGLib_OLD::TVecPool< TVal >::IdToOffV
private

Definition at line 1949 of file ds.h.

Referenced by TGLib_OLD::TVecPool< TVal >::operator=().

template<class TVal >
::TSize TGLib_OLD::TVecPool< TVal >::Vals
private

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