SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
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 1134 of file dt.h.

Constructor & Destructor Documentation

TInt::TInt ( )
inline

Definition at line 1145 of file dt.h.

Referenced by GetMemUsed().

1145 : Val(0){}
int Val
Definition: dt.h:1136

Here is the caller graph for this function:

TInt::TInt ( const int &  _Val)
inline

Definition at line 1146 of file dt.h.

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

Definition at line 1148 of file dt.h.

References TSIn::Load(), and Val.

1148 {SIn.Load(Val);}
int Val
Definition: dt.h:1136
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 1171 of file dt.h.

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

Definition at line 1214 of file dt.h.

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

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

Here is the caller graph for this function:

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

Definition at line 1216 of file dt.h.

References GetHexStr(), and Val.

1216  {
1217  return GetHexStr(Int.Val);}
static TStr GetHexStr(const int &Val)
Definition: dt.h:1214
int Val
Definition: dt.h:1136

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 1194 of file dt.h.

References IAssert, and Val.

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

1194  {
1195  IAssert(Mn<=Mx); return Val<Mn?Mn:(Val>Mx?Mx:Val);}
#define IAssert(Cond)
Definition: bd.h:262
int Val
Definition: dt.h:1136
static const int Mx
Definition: dt.h:1139
static const int Mn
Definition: dt.h:1138

Here is the caller graph for this function:

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

Definition at line 1219 of file dt.h.

References GetStr().

Referenced by GetMegaStr().

1219  {
1220  if (Val>=100*1000){return GetStr(Val/1000)+"K";}
1221  else if (Val>=1000){return GetStr(Val/1000)+"."+GetStr((Val%1000)/100)+"K";}
1222  else {return GetStr(Val);}}
TStr GetStr() const
Definition: dt.h:1197
int Val
Definition: dt.h:1136

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 1223 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().

1223  {
1224  if (Val>=100*1000000){return GetStr(Val/1000000)+"M";}
1225  else if (Val>=1000000){
1226  return GetStr(Val/1000000)+"."+GetStr((Val%1000000)/100000)+"M";}
1227  else {return GetKiloStr(Val);}}
TStr GetStr() const
Definition: dt.h:1197
int Val
Definition: dt.h:1136
static TStr GetKiloStr(const int &Val)
Definition: dt.h:1219

Here is the call graph for this function:

Here is the caller graph for this function:

int TInt::GetMemUsed ( ) const
inline

Definition at line 1166 of file dt.h.

References TInt().

Referenced by TCrossNet::TCrossEdge::GetMemUsed().

1166 {return sizeof(TInt);}
TInt()
Definition: dt.h:1145

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1180 of file dt.h.

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

1180  {
1181  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 1184 of file dt.h.

References GetMn().

1184  {
1185  return GetMn(Int1, GetMn(Int2, Int3));}
static int GetMn(const int &Int1, const int &Int2)
Definition: dt.h:1180

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 1186 of file dt.h.

References GetMn().

1187  {
1188  return GetMn(GetMn(Int1, Int2), GetMn(Int3, Int4));}
static int GetMn(const int &Int1, const int &Int2)
Definition: dt.h:1180

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 1189 of file dt.h.

References GetMx().

1189  {
1190  return GetMx(Int1, GetMx(Int2, Int3));}
static int GetMx(const int &Int1, const int &Int2)
Definition: dt.h:1182

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 1191 of file dt.h.

References GetMx().

1192  {
1193  return GetMx(GetMx(Int1, Int2), GetMx(Int3, Int4));}
static int GetMx(const int &Int1, const int &Int2)
Definition: dt.h:1182

Here is the call graph for this function:

int TInt::GetPrimHashCd ( ) const
inline

Definition at line 1168 of file dt.h.

References Val.

Referenced by TNEANetMP::AddEdgeUnchecked(), TNGraphMP::AddNodeWithEdges(), TNEANetMP::AddNodeWithEdges(), and TSnap::ToGraphMP3().

1168 {return Val;}
int Val
Definition: dt.h:1136

Here is the caller graph for this function:

static int TInt::GetRnd ( const int &  Range = 0)
inlinestatic

Definition at line 1175 of file dt.h.

References TRnd::GetUniDevInt(), and Rnd.

Referenced by TTable::GetPivot(), TTable::GetPivotKeyVal(), TVec< TVal, TSizeTy >::GetPivotValN(), and TVec< TFlt, TSizeTy >::GetPivotValNCmp().

1175 {return Rnd.GetUniDevInt(Range);}
static TRnd Rnd
Definition: dt.h:1143
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 1169 of file dt.h.

References Val.

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

Definition at line 1197 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(), TTable::RenumberColName(), 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(), TTable::SelfSimJoinPerGroup(), THttpResp::THttpResp(), THttpRq::THttpRq(), and TVecPool< TVal, TSizeTy >::TVecPool().

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

Here is the caller graph for this function:

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

Definition at line 1199 of file dt.h.

References TStr::Fmt().

1199 { return TStr::Fmt("%d", Val); }
int Val
Definition: dt.h:1136
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 1200 of file dt.h.

References GetStr(), and Val.

Referenced by GetStr().

1200 { return GetStr(Int.Val);}
TStr GetStr() const
Definition: dt.h:1197
int Val
Definition: dt.h:1136

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:1197
int Val
Definition: dt.h:1136
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 1202 of file dt.h.

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

Referenced by GetStr().

1202 { return GetStr(Val, FmtStr.CStr());}
TStr GetStr() const
Definition: dt.h:1197
int Val
Definition: dt.h:1136
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 1205 of file dt.h.

References TStr::Fmt().

1205 { return TStr::Fmt("%u", Val); }
int Val
Definition: dt.h:1136
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 1210 of file dt.h.

References TStr::Fmt().

1210 {return TStr::Fmt("%lld", Val);}
int Val
Definition: dt.h:1136
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 1211 of file dt.h.

References TStr::Fmt().

1211 {return TStr::Fmt("%llu", Val);}
int Val
Definition: dt.h:1136
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 1178 of file dt.h.

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

Definition at line 1177 of file dt.h.

1177 {return ((Int%2)==1);}
void TInt::Load ( TSIn SIn)
inline
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:1136
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 1147 of file dt.h.

References Val.

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

Definition at line 1158 of file dt.h.

References Val.

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

Definition at line 1161 of file dt.h.

References Val.

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

Definition at line 1164 of file dt.h.

References Val.

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

Definition at line 1162 of file dt.h.

References Val.

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

Definition at line 1165 of file dt.h.

References Val.

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

Definition at line 1163 of file dt.h.

References Val.

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

Definition at line 1159 of file dt.h.

References Val.

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

Definition at line 1160 of file dt.h.

References Val.

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

Definition at line 1154 of file dt.h.

References Val.

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

Definition at line 1155 of file dt.h.

References Val.

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

Definition at line 1156 of file dt.h.

References Val.

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

Definition at line 1157 of file dt.h.

References Val.

1157 {return Val==Int;}
int Val
Definition: dt.h:1136
void TInt::Save ( TSOut SOut) const
inline

Definition at line 1150 of file dt.h.

References TSOut::Save(), and Val.

Referenced by THashKeyDat< TKey, TDat >::Save(), TGraphKey::Save(), THashMPKeyDat< TKey, TDat >::Save(), TJsonVal::Save(), TAGMFit::Save(), TNodeNet< TNodeData >::TNode::Save(), TNGraphMP::TNode::Save(), TNEANetMP::TNode::Save(), TUNGraph::TNode::Save(), TAGMFast::Save(), TNEANetMP::TEdge::Save(), TModeNet::Save(), THitInfo::Save(), TEdgeInfo::Save(), TCoda::Save(), TCascade::Save(), TNodeInfo::Save(), THashMP< TInt, TEdge >::Save(), TNGraphMP::Save(), TCrossNet::TCrossEdge::Save(), TNodeNet< TSecTm >::Save(), TUNGraph::Save(), TGStatVec::Save(), TSnapQueue< int >::Save(), THash< TPair, THash >::Save(), TLocClustStat::Save(), TTm::Save(), TCesna::Save(), TNEANetMP::Save(), TSparseTable< TKey, GroupSize >::Save(), TCrossNet::Save(), TNGraph::TNode::Save(), TNGraph::Save(), TSparseHash< TKey, TDat, GroupSize >::Save(), TNodeEDatNet< TNodeData, TEdgeData >::TNode::Save(), TMMNet::Save(), TNodeEDatNet< TStr, TFltFltH >::Save(), TNEGraph::TNode::Save(), TNEGraph::TEdge::Save(), TSparseSet< TKey, GroupSize >::Save(), TNEGraph::Save(), TStrHash< TInt, TBigStrPool >::Save(), TBPGraph::TNode::Save(), TTable::Save(), THashSetKey< TKey >::Save(), TBPGraph::Save(), THashSet< TInt >::Save(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::Save(), TNodeEdgeNet< TNodeData, TEdgeData >::TEdge::Save(), TNodeEdgeNet< TSecTm, TSecTm >::Save(), TNEANet::Save(), TQQueue< TInt >::Save(), TUndirNet::Save(), TDirNet::Save(), TNEANet::Save_V1(), TUndirNet::Save_V1(), TDirNet::Save_V1(), TNEANet::Save_V2(), and TBigNet< TNodeData, IsDir >::SaveToDisk().

1150 {SOut.Save(Val);}
int Val
Definition: dt.h:1136
void Save(const bool &Bool)
Definition: fl.h:173

Here is the call graph for this function:

Here is the caller graph for this function:

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:1197
#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:1136
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:1197
#define XSaveBETagArg(Nm, ArgNm, ArgVal)
Definition: bd.h:327
int Val
Definition: dt.h:1136

Here is the call graph for this function:

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

Definition at line 1172 of file dt.h.

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

Definition at line 1173 of file dt.h.

1173  {
1174  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 1142 of file dt.h.

const int TInt::Kilo =1024
static

Definition at line 1140 of file dt.h.

const int TInt::Mega =1024*1024
static

Definition at line 1141 of file dt.h.


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