SNAP Library 2.4, Developer Reference  2015-05-11 19:40:56
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TInt Class Reference

#include <dt.h>

Collaboration diagram for TInt:

Public Member Functions

 TInt ()
 
 TInt (const int &_Val)
 
 operator int () const
 
 TInt (TSIn &SIn)
 
void Load (TSIn &SIn)
 
void Save (TSOut &SOut) const
 
void LoadXml (const PXmlTok &XmlTok, const TStr &Nm)
 
void SaveXml (TSOut &SOut, const TStr &Nm) const
 
TIntoperator= (const TInt &Int)
 
TIntoperator= (const int &Int)
 
bool operator== (const TInt &Int) const
 
bool operator== (const int &Int) const
 
bool operator!= (const int &Int) const
 
bool operator< (const TInt &Int) const
 
bool operator< (const int &Int) const
 
int operator() () const
 
TIntoperator+= (const int &Int)
 
TIntoperator-= (const int &Int)
 
TInt operator++ (int)
 
TInt operator-- (int)
 
int GetMemUsed () const
 
int GetPrimHashCd () const
 
int GetSecHashCd () const
 
TStr GetStr () const
 

Static Public Member Functions

static int Abs (const int &Int)
 
static int Sign (const int &Int)
 
static void Swap (int &Int1, int &Int2)
 
static int GetRnd (const int &Range=0)
 
static bool IsOdd (const int &Int)
 
static bool IsEven (const int &Int)
 
static int GetMn (const int &Int1, const int &Int2)
 
static int GetMx (const int &Int1, const int &Int2)
 
static int GetMn (const int &Int1, const int &Int2, const int &Int3)
 
static int GetMn (const int &Int1, const int &Int2, const int &Int3, const int &Int4)
 
static int GetMx (const int &Int1, const int &Int2, const int &Int3)
 
static int GetMx (const int &Int1, const int &Int2, const int &Int3, const int &Int4)
 
static int GetInRng (const int &Val, const int &Mn, const int &Mx)
 
static TStr GetStr (const int &Val)
 
static TStr GetStr (const TInt &Int)
 
static TStr GetStr (const int &Val, const char *FmtStr)
 
static TStr GetStr (const int &Val, const TStr &FmtStr)
 
static TStr GetStr (const uint &Val)
 
static TStr GetStr (const int64 &Val)
 
static TStr GetStr (const uint64 &Val)
 
static TStr GetHexStr (const int &Val)
 
static TStr GetHexStr (const TInt &Int)
 
static TStr GetKiloStr (const int &Val)
 
static TStr GetMegaStr (const int &Val)
 
static char * SaveFrugalInt (char *pDest, int i)
 
static char * LoadFrugalInt (char *pSrc, int &i)
 
static void TestFrugalInt ()
 
static void SaveFrugalIntV (TSOut &SOut, const TVec< TInt, int > &IntV)
 
static void LoadFrugalIntV (TSIn &SIn, TVec< TInt, int > &IntV, bool ClrP=true)
 

Public Attributes

int Val
 

Static Public Attributes

static const int Mn =INT_MIN
 
static const int Mx =INT_MAX
 
static const int Kilo =1024
 
static const int Mega =1024*1024
 
static const int Giga =1024*1024*1024
 
static TRnd Rnd
 

Detailed Description

Definition at line 1042 of file dt.h.

Constructor & Destructor Documentation

TInt::TInt ( )
inline

Definition at line 1053 of file dt.h.

Referenced by GetMemUsed().

1053 : Val(0){}
int Val
Definition: dt.h:1044

Here is the caller graph for this function:

TInt::TInt ( const int &  _Val)
inline

Definition at line 1054 of file dt.h.

1054 : Val(_Val){}
int Val
Definition: dt.h:1044
TInt::TInt ( TSIn SIn)
inlineexplicit

Definition at line 1056 of file dt.h.

References TSIn::Load(), and Val.

1056 {SIn.Load(Val);}
int Val
Definition: dt.h:1044
void Load(bool &Bool)
Definition: fl.h:84

Here is the call graph for this function:

Member Function Documentation

static int TInt::Abs ( const int &  Int)
inlinestatic

Definition at line 1079 of file dt.h.

1079 {return Int<0?-Int:Int;}
static TStr TInt::GetHexStr ( const int &  Val)
inlinestatic

Definition at line 1122 of file dt.h.

Referenced by GetHexStr(), and TUrl::GetUrlSearchStr().

1122  {
1123  char Bf[255]; sprintf(Bf, "%X", Val); return TStr(Bf);}
int Val
Definition: dt.h:1044
Definition: dt.h:412

Here is the caller graph for this function:

static TStr TInt::GetHexStr ( const TInt Int)
inlinestatic

Definition at line 1124 of file dt.h.

References GetHexStr(), and Val.

1124  {
1125  return GetHexStr(Int.Val);}
static TStr GetHexStr(const int &Val)
Definition: dt.h:1122
int Val
Definition: dt.h:1044

Here is the call graph for this function:

static int TInt::GetInRng ( const int &  Val,
const int &  Mn,
const int &  Mx 
)
inlinestatic

Definition at line 1102 of file dt.h.

References IAssert, and Val.

Referenced by TVec< TVal, TSizeTy >::GetSubValV().

1102  {
1103  IAssert(Mn<=Mx); return Val<Mn?Mn:(Val>Mx?Mx:Val);}
#define IAssert(Cond)
Definition: bd.h:262
int Val
Definition: dt.h:1044
static const int Mx
Definition: dt.h:1047
static const int Mn
Definition: dt.h:1046

Here is the caller graph for this function:

static TStr TInt::GetKiloStr ( const int &  Val)
inlinestatic

Definition at line 1127 of file dt.h.

References GetStr().

Referenced by GetMegaStr().

1127  {
1128  if (Val>=100*1000){return GetStr(Val/1000)+"K";}
1129  else if (Val>=1000){return GetStr(Val/1000)+"."+GetStr((Val%1000)/100)+"K";}
1130  else {return GetStr(Val);}}
TStr GetStr() const
Definition: dt.h:1105
int Val
Definition: dt.h:1044

Here is the call graph for this function:

Here is the caller graph for this function:

static TStr TInt::GetMegaStr ( const int &  Val)
inlinestatic

Definition at line 1131 of file dt.h.

References GetKiloStr(), and GetStr().

Referenced by TBigNet< TNodeData, IsDir >::InvertFromSources(), TBigNet< TNodeData, IsDir >::IsOk(), TLocClustStat::ParamStr(), TKroneckerLL::SampleGradient(), and TKroneckerLL::TestSamplePerm().

1131  {
1132  if (Val>=100*1000000){return GetStr(Val/1000000)+"M";}
1133  else if (Val>=1000000){
1134  return GetStr(Val/1000000)+"."+GetStr((Val%1000000)/100000)+"M";}
1135  else {return GetKiloStr(Val);}}
TStr GetStr() const
Definition: dt.h:1105
int Val
Definition: dt.h:1044
static TStr GetKiloStr(const int &Val)
Definition: dt.h:1127

Here is the call graph for this function:

Here is the caller graph for this function:

int TInt::GetMemUsed ( ) const
inline

Definition at line 1074 of file dt.h.

References TInt().

1074 {return sizeof(TInt);}
TInt()
Definition: dt.h:1053

Here is the call graph for this function:

static int TInt::GetMn ( const int &  Int1,
const int &  Int2 
)
inlinestatic

Definition at line 1088 of file dt.h.

Referenced by TVVec< TVal >::CopyFrom(), TStr::DelSubStr(), GetMn(), TMOut::GetSIn(), TChA::GetSubStr(), TStr::GetSubStr(), TQQueue< TInt >::GetSubValV(), TSparseSVD::Lanczos(), TSnap::PrintInfo(), TBigStrPool::Resize(), and TStrPool::Resize().

1088  {
1089  return Int1<Int2?Int1:Int2;}

Here is the caller graph for this function:

static int TInt::GetMn ( const int &  Int1,
const int &  Int2,
const int &  Int3 
)
inlinestatic

Definition at line 1092 of file dt.h.

References GetMn().

1092  {
1093  return GetMn(Int1, GetMn(Int2, Int3));}
static int GetMn(const int &Int1, const int &Int2)
Definition: dt.h:1088

Here is the call graph for this function:

static int TInt::GetMn ( const int &  Int1,
const int &  Int2,
const int &  Int3,
const int &  Int4 
)
inlinestatic

Definition at line 1094 of file dt.h.

References GetMn().

1095  {
1096  return GetMn(GetMn(Int1, Int2), GetMn(Int3, Int4));}
static int GetMn(const int &Int1, const int &Int2)
Definition: dt.h:1088

Here is the call graph for this function:

static int TInt::GetMx ( const int &  Int1,
const int &  Int2 
)
inlinestatic
static int TInt::GetMx ( const int &  Int1,
const int &  Int2,
const int &  Int3 
)
inlinestatic

Definition at line 1097 of file dt.h.

References GetMx().

1097  {
1098  return GetMx(Int1, GetMx(Int2, Int3));}
static int GetMx(const int &Int1, const int &Int2)
Definition: dt.h:1090

Here is the call graph for this function:

static int TInt::GetMx ( const int &  Int1,
const int &  Int2,
const int &  Int3,
const int &  Int4 
)
inlinestatic

Definition at line 1099 of file dt.h.

References GetMx().

1100  {
1101  return GetMx(GetMx(Int1, Int2), GetMx(Int3, Int4));}
static int GetMx(const int &Int1, const int &Int2)
Definition: dt.h:1090

Here is the call graph for this function:

int TInt::GetPrimHashCd ( ) const
inline

Definition at line 1076 of file dt.h.

References Val.

1076 {return Val;}
int Val
Definition: dt.h:1044
static int TInt::GetRnd ( const int &  Range = 0)
inlinestatic

Definition at line 1083 of file dt.h.

References TRnd::GetUniDevInt(), and Rnd.

Referenced by TVec< TVal, TSizeTy >::GetPivotValN(), and TVec< TSparseGroup >::GetPivotValNCmp().

1083 {return Rnd.GetUniDevInt(Range);}
static TRnd Rnd
Definition: dt.h:1051
int GetUniDevInt(const int &Range=0)
Definition: dt.cpp:39

Here is the call graph for this function:

Here is the caller graph for this function:

int TInt::GetSecHashCd ( ) const
inline

Definition at line 1077 of file dt.h.

References Val.

1077 {return Val/0x10;}
int Val
Definition: dt.h:1044
TStr TInt::GetStr ( ) const
inline

Definition at line 1105 of file dt.h.

References Val.

Referenced by TXmlTok::AddArg(), TBlobBs::AssertBlobBsStateStr(), TSnap::CmtyEvolutionJson(), TUniCodec::DecodeUtf16FromBytes(), TUniCodec::DecodeUtf16FromWords(), TUniCodec::DecodeUtf8(), TUniCodec::EncodeUtf8(), TXmlLx::EThrow(), TBlobPt::GetAddrStr(), TSecTm::GetDtTmSortFNmStr(), TSecTm::GetDtTmSortStr(), TXmlLx::GetFPosStr(), TILx::GetFPosStr(), TTmInfo::GetHmFromMins(), TTm::GetHMSTColonDotStr(), TTm::GetIdStr(), TEnv::GetIfArgPrefixInt(), TEnv::GetIfArgPrefixIntV(), GetKiloStr(), GetMegaStr(), TMom::GetNmVStr(), TStr::GetNrNumFExt(), TStr::GetNumFNm(), THttp::GetReasonPhrase(), TGnuPlot::GetSeriesPlotStr(), TBlobPt::GetStr(), TSecTm::GetStr(), THttpRq::GetStr(), TMom::GetStr(), TTm::GetStr(), GetStr(), TMom::GetValVStr(), TVec< TVal, TSizeTy >::GetXOutOfBoundsErrMsg(), TTm::GetYMDDashStr(), TSnap::Intersect(), TSnap::Intersect1(), TSnap::MaxCPGreedyBetter2(), TVecPool< TVal, TSizeTy >::operator=(), TSOut::PutInt(), TOLx::PutInt(), TVec< TVal, TSizeTy >::Resize(), TVecPool< TVal, TSizeTy >::Resize(), SaveFrugalInt(), THist::SaveStat(), THtmlDoc::SaveTxt(), TRnd::SaveXml(), TMem::SaveXml(), TChA::SaveXml(), TVec< TVal, TSizeTy >::SaveXml(), TCh::SaveXml(), TUCh::SaveXml(), SaveXml(), TUInt::SaveXml(), THttpResp::THttpResp(), THttpRq::THttpRq(), and TVecPool< TVal, TSizeTy >::TVecPool().

1105 {return TInt::GetStr(Val);}
TStr GetStr() const
Definition: dt.h:1105
int Val
Definition: dt.h:1044

Here is the caller graph for this function:

static TStr TInt::GetStr ( const int &  Val)
inlinestatic

Definition at line 1107 of file dt.h.

References TStr::Fmt().

1107 { return TStr::Fmt("%d", Val); }
int Val
Definition: dt.h:1044
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599

Here is the call graph for this function:

static TStr TInt::GetStr ( const TInt Int)
inlinestatic

Definition at line 1108 of file dt.h.

References GetStr(), and Val.

Referenced by GetStr().

1108 { return GetStr(Int.Val);}
TStr GetStr() const
Definition: dt.h:1105
int Val
Definition: dt.h:1044

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TInt::GetStr ( const int &  Val,
const char *  FmtStr 
)
static

Definition at line 1932 of file dt.cpp.

References GetStr().

1932  {
1933  if (FmtStr==NULL){
1934  return GetStr(Val);
1935  } else {
1936  char Bf[255];
1937  sprintf(Bf, FmtStr, Val);
1938  return TStr(Bf);
1939  }
1940 }
TStr GetStr() const
Definition: dt.h:1105
int Val
Definition: dt.h:1044
Definition: dt.h:412

Here is the call graph for this function:

static TStr TInt::GetStr ( const int &  Val,
const TStr FmtStr 
)
inlinestatic

Definition at line 1110 of file dt.h.

References TStr::CStr(), and GetStr().

Referenced by GetStr().

1110 { return GetStr(Val, FmtStr.CStr());}
TStr GetStr() const
Definition: dt.h:1105
int Val
Definition: dt.h:1044
char * CStr()
Definition: dt.h:476

Here is the call graph for this function:

Here is the caller graph for this function:

static TStr TInt::GetStr ( const uint Val)
inlinestatic

Definition at line 1113 of file dt.h.

References TStr::Fmt().

1113 { return TStr::Fmt("%u", Val); }
int Val
Definition: dt.h:1044
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599

Here is the call graph for this function:

static TStr TInt::GetStr ( const int64 Val)
inlinestatic

Definition at line 1118 of file dt.h.

References TStr::Fmt().

1118 {return TStr::Fmt("%lld", Val);}
int Val
Definition: dt.h:1044
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599

Here is the call graph for this function:

static TStr TInt::GetStr ( const uint64 Val)
inlinestatic

Definition at line 1119 of file dt.h.

References TStr::Fmt().

1119 {return TStr::Fmt("%llu", Val);}
int Val
Definition: dt.h:1044
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599

Here is the call graph for this function:

static bool TInt::IsEven ( const int &  Int)
inlinestatic

Definition at line 1086 of file dt.h.

1086 {return ((Int%2)==0);}
static bool TInt::IsOdd ( const int &  Int)
inlinestatic

Definition at line 1085 of file dt.h.

1085 {return ((Int%2)==1);}
void TInt::Load ( TSIn SIn)
inline

Definition at line 1057 of file dt.h.

References TSIn::Load(), and Val.

Referenced by TAGMFit::Load(), TAGMFast::Load(), TCoda::Load(), TCesna::Load(), TSparseTable< TKey, GroupSize >::Load(), TSparseHash< TKey, TDat, GroupSize >::Load(), TStrHash< TDat, TStringPool, THashFunc >::Load(), TSparseSet< TKey, GroupSize >::Load(), TVVec< TFlt >::Load(), and TKeyDatFl< TKey, TDat, THashFunc >::TKeyDatFl().

1057 {SIn.Load(Val);}
int Val
Definition: dt.h:1044
void Load(bool &Bool)
Definition: fl.h:84

Here is the call graph for this function:

Here is the caller graph for this function:

char * TInt::LoadFrugalInt ( char *  pSrc,
int &  i 
)
static

Definition at line 1975 of file dt.cpp.

Referenced by LoadFrugalIntV().

1975  {
1976  i = 0;
1977  int ch = (int) ((unsigned char) (*pSrc++));
1978  if ((ch & 0x80) == 0) { i = ch; i--; return pSrc; }
1979  i = (ch & 0x7f);
1980  ch = (int) ((unsigned char) (*pSrc++));
1981  if ((ch & 0x80) == 0)
1982  {
1983  i |= (ch & 0x3f) << 7;
1984  if ((ch & 0x40) == 0) i += 128; else i = -1 - i;
1985  i--; return pSrc;
1986  }
1987  i |= (ch & 0x7f) << 7;
1988  ch = (int) ((unsigned char) (*pSrc++));
1989  i |= ch << 14;
1990  ch = (int) ((unsigned char) (*pSrc++));
1991  i |= (ch & 0x7f) << 22;
1992  if ((ch & 0x80) == 0) i += 128 + 8192; else i = (-1 - 8192) - i;
1993  i--; return pSrc;
1994 }

Here is the caller graph for this function:

void TInt::LoadFrugalIntV ( TSIn SIn,
TVec< TInt, int > &  IntV,
bool  ClrP = true 
)
static

Definition at line 2043 of file dt.cpp.

References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::Clr(), TSIn::GetBf(), TSIn::GetCh(), IAssert, and LoadFrugalInt().

2043  {
2044  if (clearVec) v.Clr();
2045  char sizeBuf[4], *p, *pEnd;
2046  // Load the first frugally-stored integer into the sizeBuf
2047  // buffer. 'count' bytes will be read.
2048  sizeBuf[0] = SIn.GetCh(); int count = 1;
2049  if (sizeBuf[0] & 0x80)
2050  {
2051  sizeBuf[1] = SIn.GetCh(); count++;
2052  if (sizeBuf[1] & 0x80) { sizeBuf[2] = SIn.GetCh();
2053  sizeBuf[3] = SIn.GetCh(); count += 2;}
2054  }
2055  // Decode the stored size.
2056  int size;
2057  pEnd = LoadFrugalInt(&sizeBuf[0], size);
2058  IAssert(pEnd - &sizeBuf[0] == count);
2059  if (size <= 0) return;
2060  // Allocate a buffer and read the compressed data.
2061  char *buf = new char[size];
2062  SIn.GetBf(buf, size);
2063  // Decode the compressed integers and add them into 'v'.
2064  p = buf; pEnd = buf + size;
2065  while (p < pEnd)
2066  { int i; p = LoadFrugalInt(p, i); v.Add(i); }
2067  IAssert(p == pEnd);
2068  delete[] buf;
2069 }
#define IAssert(Cond)
Definition: bd.h:262
virtual int GetBf(const void *Bf, const TSize &BfL)=0
static char * LoadFrugalInt(char *pSrc, int &i)
Definition: dt.cpp:1975
virtual char GetCh()=0

Here is the call graph for this function:

void TInt::LoadXml ( const PXmlTok XmlTok,
const TStr Nm 
)

Definition at line 1923 of file dt.cpp.

References TXmlObjSer::GetIntArg(), Val, and XLoadHd.

1923  {
1924  XLoadHd(Nm);
1925  Val=TXmlObjSer::GetIntArg(XmlTok, "Val");
1926 }
#define XLoadHd(Nm)
Definition: bd.h:312
int Val
Definition: dt.h:1044
static int GetIntArg(const PXmlTok &XmlTok, const TStr &Nm)
Definition: xml.cpp:74

Here is the call graph for this function:

TInt::operator int ( ) const
inline

Definition at line 1055 of file dt.h.

References Val.

1055 {return Val;}
int Val
Definition: dt.h:1044
bool TInt::operator!= ( const int &  Int) const
inline

Definition at line 1066 of file dt.h.

References Val.

1066 {return Val!=Int;}
int Val
Definition: dt.h:1044
int TInt::operator() ( ) const
inline

Definition at line 1069 of file dt.h.

References Val.

1069 {return Val;}
int Val
Definition: dt.h:1044
TInt TInt::operator++ ( int  )
inline

Definition at line 1072 of file dt.h.

References Val.

1072 {Val++; return *this;}
int Val
Definition: dt.h:1044
TInt& TInt::operator+= ( const int &  Int)
inline

Definition at line 1070 of file dt.h.

References Val.

1070 {Val+=Int; return *this;}
int Val
Definition: dt.h:1044
TInt TInt::operator-- ( int  )
inline

Definition at line 1073 of file dt.h.

References Val.

1073 {Val--; return *this;}
int Val
Definition: dt.h:1044
TInt& TInt::operator-= ( const int &  Int)
inline

Definition at line 1071 of file dt.h.

References Val.

1071 {Val-=Int; return *this;}
int Val
Definition: dt.h:1044
bool TInt::operator< ( const TInt Int) const
inline

Definition at line 1067 of file dt.h.

References Val.

1067 {return Val<Int.Val;}
int Val
Definition: dt.h:1044
bool TInt::operator< ( const int &  Int) const
inline

Definition at line 1068 of file dt.h.

References Val.

1068 {return Val<Int;}
int Val
Definition: dt.h:1044
TInt& TInt::operator= ( const TInt Int)
inline

Definition at line 1062 of file dt.h.

References Val.

1062 {Val=Int.Val; return *this;}
int Val
Definition: dt.h:1044
TInt& TInt::operator= ( const int &  Int)
inline

Definition at line 1063 of file dt.h.

References Val.

1063 {Val=Int; return *this;}
int Val
Definition: dt.h:1044
bool TInt::operator== ( const TInt Int) const
inline

Definition at line 1064 of file dt.h.

References Val.

1064 {return Val==Int.Val;}
int Val
Definition: dt.h:1044
bool TInt::operator== ( const int &  Int) const
inline

Definition at line 1065 of file dt.h.

References Val.

1065 {return Val==Int;}
int Val
Definition: dt.h:1044
void TInt::Save ( TSOut SOut) const
inline
char * TInt::SaveFrugalInt ( char *  pDest,
int  i 
)
static

Definition at line 1954 of file dt.cpp.

References GetStr(), and IAssertR.

Referenced by SaveFrugalIntV().

1954  {
1955  // <0xxx xxxx> has 128 combinations and is used to store -1..126.
1956  // <1xxx xxxx> <00xx xxxx> has 2^13 = 8192 combinations and is used to store 127..8318.
1957  // <1xxx xxxx> <01xx xxxx> has 2^13 = 8192 combinations and is used to store -2..-8193.
1958  // <1xxx xxxx> <1xxx xxxx> <xxxx xxxx> <0xxx xxxx> has 2^29 = 536870912 combinations and is used to store 8319..536879230.
1959  // <1xxx xxxx> <1xxx xxxx> <xxxx xxxx> <1xxx xxxx> has 2^29 = 536870912 combinations and is used to store -8194..-536879105.
1960  i++;
1961  if (i >= 0 && i <= 127) { *pDest++ = char(i); return pDest; }
1962  if (i >= 128 && i < 128 + 8192) { i -= 128; *pDest++ = char(0x80 | (i & 0x7f));
1963  *pDest++ = char((i >> 7) & 0x3f); return pDest; }
1964  if (i <= -1 && i > -1 - 8192) { i = -1 - i; *pDest++ = char(0x80 | (i & 0x7f));
1965  *pDest++ = char(0x40 | ((i >> 7) & 0x3f)); return pDest; }
1966  if (i >= 128 + 8192 && i < 128 + 8192 + 536870912) { i -= 128 + 8192;
1967  *pDest++ = char(0x80 | (i & 0x7f)); *pDest++ = char(0x80 | ((i >> 7) & 0x7f));
1968  *pDest++ = char((i >> 14) & 0xff); *pDest++ = char((i >> 22) & 0x7f); return pDest; }
1969  if (i <= -1 - 8192 && i > -1 - 8192 - 536870912) { i = (-1 - 8192) - i;
1970  *pDest++ = char(0x80 | (i & 0x7f)); *pDest++ = char(0x80 | ((i >> 7) & 0x7f));
1971  *pDest++ = char((i >> 14) & 0xff); *pDest++ = char(0x80 | ((i >> 22) & 0x7f)); return pDest; }
1972  IAssertR(false, TInt::GetStr(i)); return 0;
1973 }
TStr GetStr() const
Definition: dt.h:1105
#define IAssertR(Cond, Reason)
Definition: bd.h:265

Here is the call graph for this function:

Here is the caller graph for this function:

void TInt::SaveFrugalIntV ( TSOut SOut,
const TVec< TInt, int > &  IntV 
)
static

Definition at line 2018 of file dt.cpp.

References TVec< TVal, TSizeTy >::Len(), TSOut::PutBf(), SaveFrugalInt(), and Val.

2018  {
2019  // Prepare a large enough buffer.
2020  int count = v.Len();
2021  char *buf = new char[4 * (count + 1)], *pStart, *pEnd;
2022  // Encode the contents of 'v'.
2023  pStart = buf + 4; pEnd = pStart;
2024  for (int i = 0; i < count; i++)
2025  pEnd = SaveFrugalInt(pEnd, v[i].Val);
2026  // Encode the size of the encoded contents of 'v'.
2027  // This is stored at the beginning of 'buf' and is then
2028  // moved so that there is no gap between it and the
2029  // beginning of the stored contents (at pStart).
2030  int size = int(pEnd - pStart);
2031  char *pSizeStart = buf;
2032  char *pSizeEnd = SaveFrugalInt(pSizeStart, size);
2033  while (pSizeEnd > pSizeStart) *(--pStart) = *(--pSizeEnd);
2034  // Write the buffer and free the memory.
2035  SOut.PutBf(pStart, TSize(pEnd - pStart));
2036  delete[] buf;
2037 }
virtual int PutBf(const void *LBf, const TSize &LBfL)=0
int Val
Definition: dt.h:1044
static char * SaveFrugalInt(char *pDest, int i)
Definition: dt.cpp:1954
size_t TSize
Definition: bd.h:58

Here is the call graph for this function:

void TInt::SaveXml ( TSOut SOut,
const TStr Nm 
) const

Definition at line 1928 of file dt.cpp.

References GetStr(), Val, and XSaveBETagArg.

1928  {
1929  XSaveBETagArg(Nm, "Val", TInt::GetStr(Val));
1930 }
TStr GetStr() const
Definition: dt.h:1105
#define XSaveBETagArg(Nm, ArgNm, ArgVal)
Definition: bd.h:327
int Val
Definition: dt.h:1044

Here is the call graph for this function:

static int TInt::Sign ( const int &  Int)
inlinestatic

Definition at line 1080 of file dt.h.

1080 {return Int<0?-1:(Int>0?1:0);}
static void TInt::Swap ( int &  Int1,
int &  Int2 
)
inlinestatic

Definition at line 1081 of file dt.h.

1081  {
1082  int SwapInt1=Int1; Int1=Int2; Int2=SwapInt1;}
void TInt::TestFrugalInt ( )
static

Definition at line 1998 of file dt.cpp.

References __TEST.

1998  {
1999  char buf[10], *p = &buf[0], *r, *s;
2000  int i, j;
2001 #define __TEST(from, to, len) \
2002  for (i = (from); i <= (to); i++) \
2003  { if ((i & 0xffff) == 0) printf("%d\r", i); \
2004  r = SaveFrugalInt(p, i); s = LoadFrugalInt(p, j); \
2005  IAssert(r == s); IAssert(i == j); IAssert(r - p == len); }
2006 
2007  __TEST(-1, 126, 1);
2008  __TEST(127, 127 + 8191, 2);
2009  __TEST(-2 - 8191, -2, 2);
2010  __TEST(127 + 8192, 127 + 8191 + (1 << 29), 4);
2011  __TEST(-2 - 8191 - (1 << 29), -2 - 8192, 4);
2012 #undef __TEST
2013 }
#define __TEST(from, to, len)

Member Data Documentation

const int TInt::Giga =1024*1024*1024
static

Definition at line 1050 of file dt.h.

const int TInt::Kilo =1024
static

Definition at line 1048 of file dt.h.

const int TInt::Mega =1024*1024
static

Definition at line 1049 of file dt.h.

const int TInt::Mn =INT_MIN
static

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