SNAP Library 2.0, Developer Reference
2013-05-13 16:33:57
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <dt.h>
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 |
TInt & | operator= (const TInt &Int) |
TInt & | operator= (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 |
TInt & | operator+= (const int &Int) |
TInt & | operator-= (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 |
TInt::TInt | ( | ) | [inline] |
Definition at line 1052 of file dt.h.
Referenced by GetMemUsed().
: Val(0){}
TInt::TInt | ( | const int & | _Val | ) | [inline] |
TInt::TInt | ( | TSIn & | SIn | ) | [inline, explicit] |
static int TInt::Abs | ( | const int & | Int | ) | [inline, static] |
static TStr TInt::GetHexStr | ( | const int & | Val | ) | [inline, static] |
Definition at line 1121 of file dt.h.
Referenced by GetHexStr(), and TUrl::GetUrlSearchStr().
static TStr TInt::GetHexStr | ( | const TInt & | Int | ) | [inline, static] |
static int TInt::GetInRng | ( | const int & | Val, |
const int & | Mn, | ||
const int & | Mx | ||
) | [inline, static] |
static TStr TInt::GetKiloStr | ( | const int & | Val | ) | [inline, static] |
Definition at line 1126 of file dt.h.
References GetStr().
Referenced by GetMegaStr().
{ if (Val>=100*1000){return GetStr(Val/1000)+"K";} else if (Val>=1000){return GetStr(Val/1000)+"."+GetStr((Val%1000)/100)+"K";} else {return GetStr(Val);}}
static TStr TInt::GetMegaStr | ( | const int & | Val | ) | [inline, static] |
Definition at line 1130 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().
{ if (Val>=100*1000000){return GetStr(Val/1000000)+"M";} else if (Val>=1000000){ return GetStr(Val/1000000)+"."+GetStr((Val%1000000)/100000)+"M";} else {return GetKiloStr(Val);}}
int TInt::GetMemUsed | ( | ) | const [inline] |
static int TInt::GetMn | ( | const int & | Int1, |
const int & | Int2 | ||
) | [inline, static] |
Definition at line 1087 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().
{
return Int1<Int2?Int1:Int2;}
static int TInt::GetMn | ( | const int & | Int1, |
const int & | Int2, | ||
const int & | Int3 | ||
) | [inline, static] |
static int TInt::GetMn | ( | const int & | Int1, |
const int & | Int2, | ||
const int & | Int3, | ||
const int & | Int4 | ||
) | [inline, static] |
static int TInt::GetMx | ( | const int & | Int1, |
const int & | Int2 | ||
) | [inline, static] |
Definition at line 1089 of file dt.h.
Referenced by TTmProfiler::AddTimer(), TChA::CountCh(), TStr::CountCh(), TStr::DelSubStr(), GetMx(), TChA::GetSubStr(), TStr::GetSubStr(), TVec< TVal, TSizeTy >::GetSubValV(), TGLib_OLD::TVec< TVal >::GetSubValV(), TQQueue< TInt >::GetSubValV(), TSs::GetXLen(), TSnap::PrintInfo(), TChA::SearchCh(), TStr::SearchCh(), TStr::SearchStr(), TVec< TVal, TSizeTy >::Union(), and TGLib_OLD::TVec< TVal >::Union().
{
return Int1>Int2?Int1:Int2;}
static int TInt::GetMx | ( | const int & | Int1, |
const int & | Int2, | ||
const int & | Int3 | ||
) | [inline, static] |
static int TInt::GetMx | ( | const int & | Int1, |
const int & | Int2, | ||
const int & | Int3, | ||
const int & | Int4 | ||
) | [inline, static] |
int TInt::GetPrimHashCd | ( | ) | const [inline] |
static int TInt::GetRnd | ( | const int & | Range = 0 | ) | [inline, static] |
Definition at line 1082 of file dt.h.
References TRnd::GetUniDevInt(), and Rnd.
Referenced by TVec< TVal, TSizeTy >::GetPivotValN(), TGLib_OLD::TVec< TVal >::GetPivotValN(), TVec< THKeyDat >::GetPivotValNCmp(), and TGLib_OLD::TVec< ::TSize >::GetPivotValNCmp().
{return Rnd.GetUniDevInt(Range);}
int TInt::GetSecHashCd | ( | ) | const [inline] |
TStr TInt::GetStr | ( | ) | const [inline] |
Definition at line 1104 of file dt.h.
References Val.
Referenced by TXmlTok::AddArg(), TBlobBs::AssertBlobBsStateStr(), TUniCodec::DecodeUtf16FromBytes(), TUniCodec::DecodeUtf16FromWords(), TUniCodec::DecodeUtf8(), TUniCodec::EncodeUtf8(), TXmlLx::EThrow(), TBlobPt::GetAddrStr(), TXmlLx::GetFPosStr(), TTmInfo::GetHmFromMins(), TEnv::GetIfArgPrefixInt(), TEnv::GetIfArgPrefixIntV(), GetKiloStr(), GetMegaStr(), THttp::GetReasonPhrase(), TGnuPlot::GetSeriesPlotStr(), GetStr(), TVec< TVal, TSizeTy >::GetXOutOfBoundsErrMsg(), TGLib_OLD::TVec< TVal >::GetXOutOfBoundsErrMsg(), TUniCodec::IsMachineLittleEndian(), 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(), and TVecPool< TVal, TSizeTy >::TVecPool().
{return TInt::GetStr(Val);}
static TStr TInt::GetStr | ( | const int & | Val | ) | [inline, static] |
Definition at line 1106 of file dt.h.
References TStr::Fmt().
static TStr TInt::GetStr | ( | const TInt & | Int | ) | [inline, static] |
TStr TInt::GetStr | ( | const int & | Val, |
const char * | FmtStr | ||
) | [static] |
static TStr TInt::GetStr | ( | const int & | Val, |
const TStr & | FmtStr | ||
) | [inline, static] |
static TStr TInt::GetStr | ( | const uint & | Val | ) | [inline, static] |
Definition at line 1112 of file dt.h.
References TStr::Fmt().
static TStr TInt::GetStr | ( | const int64 & | Val | ) | [inline, static] |
Definition at line 1117 of file dt.h.
References TStr::Fmt().
static TStr TInt::GetStr | ( | const uint64 & | Val | ) | [inline, static] |
Definition at line 1118 of file dt.h.
References TStr::Fmt().
static bool TInt::IsEven | ( | const int & | Int | ) | [inline, static] |
static bool TInt::IsOdd | ( | const int & | Int | ) | [inline, static] |
void TInt::Load | ( | TSIn & | SIn | ) | [inline] |
Definition at line 1056 of file dt.h.
References TSIn::Load(), and Val.
Referenced by TAGMFit::Load(), TAGMFast::Load(), TSparseTable< THashKeyDat, 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().
char * TInt::LoadFrugalInt | ( | char * | pSrc, |
int & | i | ||
) | [static] |
Definition at line 1975 of file dt.cpp.
Referenced by LoadFrugalIntV().
{ i = 0; int ch = (int) ((unsigned char) (*pSrc++)); if ((ch & 0x80) == 0) { i = ch; i--; return pSrc; } i = (ch & 0x7f); ch = (int) ((unsigned char) (*pSrc++)); if ((ch & 0x80) == 0) { i |= (ch & 0x3f) << 7; if ((ch & 0x40) == 0) i += 128; else i = -1 - i; i--; return pSrc; } i |= (ch & 0x7f) << 7; ch = (int) ((unsigned char) (*pSrc++)); i |= ch << 14; ch = (int) ((unsigned char) (*pSrc++)); i |= (ch & 0x7f) << 22; if ((ch & 0x80) == 0) i += 128 + 8192; else i = (-1 - 8192) - i; i--; return pSrc; }
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().
{ if (clearVec) v.Clr(); char sizeBuf[4], *p, *pEnd; // Load the first frugally-stored integer into the sizeBuf // buffer. 'count' bytes will be read. sizeBuf[0] = SIn.GetCh(); int count = 1; if (sizeBuf[0] & 0x80) { sizeBuf[1] = SIn.GetCh(); count++; if (sizeBuf[1] & 0x80) { sizeBuf[2] = SIn.GetCh(); sizeBuf[3] = SIn.GetCh(); count += 2;} } // Decode the stored size. int size; pEnd = LoadFrugalInt(&sizeBuf[0], size); IAssert(pEnd - &sizeBuf[0] == count); if (size <= 0) return; // Allocate a buffer and read the compressed data. char *buf = new char[size]; SIn.GetBf(buf, size); // Decode the compressed integers and add them into 'v'. p = buf; pEnd = buf + size; while (p < pEnd) { int i; p = LoadFrugalInt(p, i); v.Add(i); } IAssert(p == pEnd); delete[] buf; }
void TInt::LoadXml | ( | const PXmlTok & | XmlTok, |
const TStr & | Nm | ||
) |
Definition at line 1923 of file dt.cpp.
References TXmlObjSer::GetIntArg(), Val, and XLoadHd.
{ XLoadHd(Nm); Val=TXmlObjSer::GetIntArg(XmlTok, "Val"); }
TInt::operator int | ( | ) | const [inline] |
bool TInt::operator!= | ( | const int & | Int | ) | const [inline] |
int TInt::operator() | ( | ) | const [inline] |
TInt TInt::operator++ | ( | int | ) | [inline] |
TInt& TInt::operator+= | ( | const int & | Int | ) | [inline] |
TInt TInt::operator-- | ( | int | ) | [inline] |
TInt& TInt::operator-= | ( | const int & | Int | ) | [inline] |
bool TInt::operator< | ( | const TInt & | Int | ) | const [inline] |
bool TInt::operator< | ( | const int & | Int | ) | const [inline] |
TInt& TInt::operator= | ( | const int & | Int | ) | [inline] |
bool TInt::operator== | ( | const TInt & | Int | ) | const [inline] |
bool TInt::operator== | ( | const int & | Int | ) | const [inline] |
void TInt::Save | ( | TSOut & | SOut | ) | const [inline] |
Definition at line 1057 of file dt.h.
References TSOut::Save(), and Val.
Referenced by TFHash< TKey, TFDat, TVDat >::AddDat(), TFHash< TKey, TFDat, TVDat >::AddKey(), TFHashKey< TKey, TFDat, TVDat >::OnDelFromCache(), THashKeyDat< TKey, TDat >::Save(), TGraphKey::Save(), TJsonVal::Save(), TNodeNet< TNodeData >::TNode::Save(), TAGMFit::Save(), TPpVal::Save(), TUNGraph::TNode::Save(), TAGMFast::Save(), THitInfo::Save(), TEdgeInfo::Save(), TCascade::Save(), TPp::Save(), TNodeInfo::Save(), THash< TIntPr, TEdgeInfo >::Save(), TSnapQueue< int >::Save(), TNodeNet< TSecTm >::Save(), TUNGraph::Save(), TGStatVec::Save(), TLocClustStat::Save(), TTm::Save(), TNGraph::TNode::Save(), TSparseTable< THashKeyDat, GroupSize >::Save(), TNGraph::Save(), TNodeEDatNet< TNodeData, TEdgeData >::TNode::Save(), TSparseHash< TKey, TDat, GroupSize >::Save(), TNEGraph::TNode::Save(), TNEGraph::TEdge::Save(), TNodeEDatNet< TStr, TFltFltH >::Save(), TNEGraph::Save(), TStrHash< TDat, TStringPool, THashFunc >::Save(), TSparseSet< TKey, GroupSize >::Save(), TBPGraph::TNode::Save(), TBPGraph::Save(), THashSetKey< TKey >::Save(), TNodeEdgeNet< TNodeData, TEdgeData >::TNode::Save(), TNodeEdgeNet< TNodeData, TEdgeData >::TEdge::Save(), THashSet< TInt >::Save(), TNodeEdgeNet< TSecTm, TSecTm >::Save(), TVVec< TFlt >::Save(), TVVVec< TVal >::Save(), TQQueue< TInt >::Save(), TBigNet< TNodeData, IsDir >::SaveToDisk(), and TFHash< TKey, TFDat, TVDat >::TFHash().
char * TInt::SaveFrugalInt | ( | char * | pDest, |
int | i | ||
) | [static] |
Definition at line 1954 of file dt.cpp.
References GetStr(), and IAssertR.
Referenced by SaveFrugalIntV().
{ // <0xxx xxxx> has 128 combinations and is used to store -1..126. // <1xxx xxxx> <00xx xxxx> has 2^13 = 8192 combinations and is used to store 127..8318. // <1xxx xxxx> <01xx xxxx> has 2^13 = 8192 combinations and is used to store -2..-8193. // <1xxx xxxx> <1xxx xxxx> <xxxx xxxx> <0xxx xxxx> has 2^29 = 536870912 combinations and is used to store 8319..536879230. // <1xxx xxxx> <1xxx xxxx> <xxxx xxxx> <1xxx xxxx> has 2^29 = 536870912 combinations and is used to store -8194..-536879105. i++; if (i >= 0 && i <= 127) { *pDest++ = char(i); return pDest; } if (i >= 128 && i < 128 + 8192) { i -= 128; *pDest++ = char(0x80 | (i & 0x7f)); *pDest++ = char((i >> 7) & 0x3f); return pDest; } if (i <= -1 && i > -1 - 8192) { i = -1 - i; *pDest++ = char(0x80 | (i & 0x7f)); *pDest++ = char(0x40 | ((i >> 7) & 0x3f)); return pDest; } if (i >= 128 + 8192 && i < 128 + 8192 + 536870912) { i -= 128 + 8192; *pDest++ = char(0x80 | (i & 0x7f)); *pDest++ = char(0x80 | ((i >> 7) & 0x7f)); *pDest++ = char((i >> 14) & 0xff); *pDest++ = char((i >> 22) & 0x7f); return pDest; } if (i <= -1 - 8192 && i > -1 - 8192 - 536870912) { i = (-1 - 8192) - i; *pDest++ = char(0x80 | (i & 0x7f)); *pDest++ = char(0x80 | ((i >> 7) & 0x7f)); *pDest++ = char((i >> 14) & 0xff); *pDest++ = char(0x80 | ((i >> 22) & 0x7f)); return pDest; } IAssertR(false, TInt::GetStr(i)); return 0; }
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.
{ // Prepare a large enough buffer. int count = v.Len(); char *buf = new char[4 * (count + 1)], *pStart, *pEnd; // Encode the contents of 'v'. pStart = buf + 4; pEnd = pStart; for (int i = 0; i < count; i++) pEnd = SaveFrugalInt(pEnd, v[i].Val); // Encode the size of the encoded contents of 'v'. // This is stored at the beginning of 'buf' and is then // moved so that there is no gap between it and the // beginning of the stored contents (at pStart). int size = int(pEnd - pStart); char *pSizeStart = buf; char *pSizeEnd = SaveFrugalInt(pSizeStart, size); while (pSizeEnd > pSizeStart) *(--pStart) = *(--pSizeEnd); // Write the buffer and free the memory. SOut.PutBf(pStart, TSize(pEnd - pStart)); delete[] buf; }
void TInt::SaveXml | ( | TSOut & | SOut, |
const TStr & | Nm | ||
) | const |
Definition at line 1928 of file dt.cpp.
References GetStr(), Val, and XSaveBETagArg.
{ XSaveBETagArg(Nm, "Val", TInt::GetStr(Val)); }
static int TInt::Sign | ( | const int & | Int | ) | [inline, static] |
static void TInt::Swap | ( | int & | Int1, |
int & | Int2 | ||
) | [inline, static] |
void TInt::TestFrugalInt | ( | ) | [static] |
Definition at line 1998 of file dt.cpp.
References __TEST.
{ char buf[10], *p = &buf[0], *r, *s; int i, j; #define __TEST(from, to, len) \ for (i = (from); i <= (to); i++) \ { if ((i & 0xffff) == 0) printf("%d\r", i); \ r = SaveFrugalInt(p, i); s = LoadFrugalInt(p, j); \ IAssert(r == s); IAssert(i == j); IAssert(r - p == len); } __TEST(-1, 126, 1); __TEST(127, 127 + 8191, 2); __TEST(-2 - 8191, -2, 2); __TEST(127 + 8192, 127 + 8191 + (1 << 29), 4); __TEST(-2 - 8191 - (1 << 29), -2 - 8192, 4); #undef __TEST }
const int TInt::Giga = 1024*1024*1024 [static] |
const int TInt::Kilo = 1024 [static] |
const int TInt::Mega = 1024*1024 [static] |
const int TInt::Mn = INT_MIN [static] |
Definition at line 1045 of file dt.h.
Referenced by TExpVal::GetFltValAsInt().
const int TInt::Mx = INT_MAX [static] |
Definition at line 1046 of file dt.h.
Referenced by TBigNet< TNodeData, IsDir >::AddSorted(), TSnap::TSnapDetail::CmtyGirvanNewmanStep(), TSnap::GetBfsEffDiam(), TSnap::GetBfsTree(), TStrUtil::GetDomNm2(), TSnap::GetFarnessCentr(), TExpVal::GetFltValAsInt(), TGraphAnf< PGraph >::GetGraphAnf(), TGraphAnf< PGraph >::GetNodeAnf(), TSnap::GetNodeEcc(), TSnap::GetNodesAtHops(), TStrUtil::GetNormalizedUrl(), TVec< TVal, TSizeTy >::GetPivotValN(), TVec< THKeyDat >::GetPivotValNCmp(), TFlt::GetPrimHashCd(), TSFlt::GetPrimHashCd(), TSnap::GetShortPath(), TSnap::GetSubTreeSz(), TGraphAnf< PGraph >::InitAnfBits(), TBigNet< TNodeData, IsDir >::InvertFromSources(), TSnap::PlotShortPathDistr(), TSecTm::SaveTxt(), and TVec< TVal, TSizeTy >::Shuffle().
Definition at line 1050 of file dt.h.
Referenced by TNIBs::BSG(), TNetInfBs::GenCascade(), TNIBs::GenCascade(), TSnap::GenDegSeq(), TSnap::GenPrefAttach(), TSnap::GetBetweennessCentr(), TSnap::GetBfsEffDiam(), TTimeNENet::GetGnmRndNet(), TSnap::GetMxDegNId(), TSnap::GetMxInDegNId(), TSnap::GetMxOutDegNId(), TTimeNENet::GetPrefAttach(), GetRnd(), TSnap::TSnapDetail::GetRndEdgeNonAdjNode(), TSnap::GetRndESubGraph(), TCnCom::GetRndNId(), TBreathFS< PGraph >::GetRndPath(), TSnap::GetRndSubGraph(), main(), TTimeNet::PlotEffDiam(), TLocClust::PlotNCP(), TSnap::PlotShortPathDistr(), TTimeNENet::SetRndEdgeTimes(), TNIBs::SG(), and TGnuPlot::Test().
int TInt::Val |
Definition at line 1043 of file dt.h.
Referenced by TLocClustStat::BagOfWhiskers(), TAGMFast::FindComsByCV(), TNetInfBs::GenCascade(), TNIBs::GenCascade(), TLocClustStat::GetBoltzmanCurveStat(), TSnap::GetClustCf(), TLocClustStat::GetCurveStat(), GetHexStr(), TBreathFS< PGraph >::GetHops(), GetInRng(), GetPrimHashCd(), GetSecHashCd(), GetStr(), Load(), LoadXml(), operator int(), operator!=(), operator()(), operator++(), operator+=(), operator--(), operator-=(), operator<(), operator=(), operator==(), TLocClustStat::PlotBestClustDens(), TLocClustStat::PlotNCPModul(), Save(), TNetInfBs::SaveEdgeInfo(), SaveFrugalIntV(), SaveXml(), TLocClustStat::TCutInfo::TCutInfo(), TInt(), and TBPGraph::TNode::TNode().