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
TKeyDatFl< TKey, TDat, THashFunc > Class Template Reference

#include <shash.h>

Collaboration diagram for TKeyDatFl< TKey, TDat, THashFunc >:

Public Member Functions

 TKeyDatFl (const TStr &FNm)
 
int Len () const
 
bool Next ()
 
const TKey & GetKey () const
 
TKey & GetKey ()
 
const TDat & GetDat () const
 
TDat & GetDat ()
 

Static Public Member Functions

static void Save (const TStr &OutFNm, const THash< TKey, TDat, THashFunc > &Hash)
 
static void Save (TSOut &SOut, const THash< TKey, TDat, THashFunc > &Hash)
 
static void LoadHash (const TStr &InFNm, THash< TKey, TDat, THashFunc > &Hash, const int &LoadN=-1)
 
static void LoadHash (TSIn &SIn, THash< TKey, TDat, THashFunc > &Hash, int LoadN=-1)
 
static void LoadKeyV (TSIn &SIn, TVec< TKey > &KeyV, int LoadN=-1)
 
static void LoadDatV (TSIn &SIn, TVec< TDat > &DatV, int LoadN=-1)
 

Private Attributes

TInt ElemCnt
 
TFIn FIn
 
TKey Key
 
TDat Dat
 

Detailed Description

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
class TKeyDatFl< TKey, TDat, THashFunc >

Definition at line 10 of file shash.h.

Constructor & Destructor Documentation

template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
TKeyDatFl< TKey, TDat, THashFunc >::TKeyDatFl ( const TStr FNm)
inline

Definition at line 17 of file shash.h.

References TKeyDatFl< TKey, TDat, THashFunc >::ElemCnt, TKeyDatFl< TKey, TDat, THashFunc >::FIn, and TInt::Load().

17 : FIn(FNm) { ElemCnt.Load(FIn); }
TFIn FIn
Definition: shash.h:13
TInt ElemCnt
Definition: shash.h:12
void Load(TSIn &SIn)
Definition: dt.h:1149

Here is the call graph for this function:

Member Function Documentation

template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
const TDat& TKeyDatFl< TKey, TDat, THashFunc >::GetDat ( ) const
inline

Definition at line 23 of file shash.h.

References TKeyDatFl< TKey, TDat, THashFunc >::Dat.

23 { return Dat; }
TDat Dat
Definition: shash.h:15
template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
TDat& TKeyDatFl< TKey, TDat, THashFunc >::GetDat ( )
inline

Definition at line 24 of file shash.h.

References TKeyDatFl< TKey, TDat, THashFunc >::Dat.

24 { return Dat; }
TDat Dat
Definition: shash.h:15
template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
const TKey& TKeyDatFl< TKey, TDat, THashFunc >::GetKey ( ) const
inline

Definition at line 21 of file shash.h.

References TKeyDatFl< TKey, TDat, THashFunc >::Key.

21 { return Key; }
TKey Key
Definition: shash.h:14
template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
TKey& TKeyDatFl< TKey, TDat, THashFunc >::GetKey ( )
inline

Definition at line 22 of file shash.h.

References TKeyDatFl< TKey, TDat, THashFunc >::Key.

22 { return Key; }
TKey Key
Definition: shash.h:14
template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
int TKeyDatFl< TKey, TDat, THashFunc >::Len ( ) const
inline

Definition at line 18 of file shash.h.

References TKeyDatFl< TKey, TDat, THashFunc >::ElemCnt.

18 { return ElemCnt; }
TInt ElemCnt
Definition: shash.h:12
template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
static void TKeyDatFl< TKey, TDat, THashFunc >::LoadDatV ( TSIn SIn,
TVec< TDat > &  DatV,
int  LoadN = -1 
)
inlinestatic

Definition at line 49 of file shash.h.

References TVec< TVal, TSizeTy >::Add(), TStr::CStr(), TKeyDatFl< TKey, TDat, THashFunc >::ElemCnt, TVec< TVal, TSizeTy >::Gen(), and TSBase::GetSNm().

49  {
50  TInt ElemCnt(SIn); const int Start=clock();
51  if (ElemCnt < LoadN || LoadN == -1) { LoadN = ElemCnt; }
52  printf("Loading %s: %d elements ... ", SIn.GetSNm().CStr(), LoadN); DatV.Gen(LoadN, 0);
53  for (int i = 0; i < LoadN; i++) { TKey(SIn); DatV.Add(TDat(SIn)); }
54  printf(" [%ds]\n", int((clock()-Start)/CLOCKS_PER_SEC));
55  }
TInt ElemCnt
Definition: shash.h:12
Definition: dt.h:1134
virtual TStr GetSNm() const
Definition: fl.cpp:20
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523
char * CStr()
Definition: dt.h:476
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:

template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
static void TKeyDatFl< TKey, TDat, THashFunc >::LoadHash ( const TStr InFNm,
THash< TKey, TDat, THashFunc > &  Hash,
const int &  LoadN = -1 
)
inlinestatic

Definition at line 33 of file shash.h.

References TKeyDatFl< TKey, TDat, THashFunc >::FIn.

33  {
34  TFIn FIn(InFNm); Load(FIn, Hash, LoadN); }
Definition: fl.h:275
TFIn FIn
Definition: shash.h:13
template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
static void TKeyDatFl< TKey, TDat, THashFunc >::LoadHash ( TSIn SIn,
THash< TKey, TDat, THashFunc > &  Hash,
int  LoadN = -1 
)
inlinestatic

Definition at line 35 of file shash.h.

References THash< TKey, TDat, THashFunc >::AddDat(), TStr::CStr(), TKeyDatFl< TKey, TDat, THashFunc >::ElemCnt, THash< TKey, TDat, THashFunc >::Gen(), and TSBase::GetSNm().

35  {
36  TInt ElemCnt(SIn); const int Start=clock();
37  if (ElemCnt < LoadN || LoadN == -1) { LoadN = ElemCnt; }
38  printf("Loading %s: %d elements ... ", SIn.GetSNm().CStr(), LoadN); Hash.Gen(LoadN);
39  for (int i = 0; i < LoadN; i++) { Hash.AddDat(TKey(SIn)).Load(SIn); }
40  printf(" [%ds]\n", int((clock()-Start)/CLOCKS_PER_SEC));
41  }
void Gen(const int &ExpectVals)
Definition: hash.h:222
TInt ElemCnt
Definition: shash.h:12
Definition: dt.h:1134
virtual TStr GetSNm() const
Definition: fl.cpp:20
char * CStr()
Definition: dt.h:476
TDat & AddDat(const TKey &Key)
Definition: hash.h:238

Here is the call graph for this function:

template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
static void TKeyDatFl< TKey, TDat, THashFunc >::LoadKeyV ( TSIn SIn,
TVec< TKey > &  KeyV,
int  LoadN = -1 
)
inlinestatic

Definition at line 42 of file shash.h.

References TVec< TVal, TSizeTy >::Add(), TStr::CStr(), TKeyDatFl< TKey, TDat, THashFunc >::ElemCnt, TVec< TVal, TSizeTy >::Gen(), and TSBase::GetSNm().

42  {
43  TInt ElemCnt(SIn); const int Start=clock();
44  if (ElemCnt < LoadN || LoadN == -1) { LoadN = ElemCnt; }
45  printf("Loading %s: %d elements ... ", SIn.GetSNm().CStr(), LoadN); KeyV.Gen(LoadN, 0);
46  for (int i = 0; i < LoadN; i++) { KeyV.Add(TKey(SIn)); TDat D(SIn); }
47  printf(" [%ds]\n", int((clock()-Start)/CLOCKS_PER_SEC));
48  }
TInt ElemCnt
Definition: shash.h:12
Definition: dt.h:1134
virtual TStr GetSNm() const
Definition: fl.cpp:20
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523
char * CStr()
Definition: dt.h:476
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:

template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
bool TKeyDatFl< TKey, TDat, THashFunc >::Next ( )
inline

Definition at line 19 of file shash.h.

References TKeyDatFl< TKey, TDat, THashFunc >::Dat, TFIn::Eof(), TKeyDatFl< TKey, TDat, THashFunc >::FIn, and TKeyDatFl< TKey, TDat, THashFunc >::Key.

19  { if (FIn.Eof()) { return false; }
20  Key.Load(FIn); Dat.Load(FIn); return true; }
TDat Dat
Definition: shash.h:15
TFIn FIn
Definition: shash.h:13
bool Eof()
Definition: fl.h:298
TKey Key
Definition: shash.h:14

Here is the call graph for this function:

template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
static void TKeyDatFl< TKey, TDat, THashFunc >::Save ( const TStr OutFNm,
const THash< TKey, TDat, THashFunc > &  Hash 
)
inlinestatic

Definition at line 26 of file shash.h.

26  {
27  TFOut FOut(OutFNm); Load(FOut, Hash); }
Definition: fl.h:319
template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
static void TKeyDatFl< TKey, TDat, THashFunc >::Save ( TSOut SOut,
const THash< TKey, TDat, THashFunc > &  Hash 
)
inlinestatic

Definition at line 28 of file shash.h.

References THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), THash< TKey, TDat, THashFunc >::GetKey(), THash< TKey, TDat, THashFunc >::Len(), TSOut::Save(), and THash< TKey, TDat, THashFunc >::Save().

28  {
29  SOut.Save(Hash.Len());
30  for (int k = Hash.FFirstKeyId(); Hash.FNextKeyId(k); ) {
31  Hash.GetKey(k).Save(SOut); Hash[k].Save(SOut); }
32  }
void Save(TSOut &SOut) const
Definition: hash.h:183
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
int FFirstKeyId() const
Definition: hash.h:278
void Save(const bool &Bool)
Definition: fl.h:173
int Len() const
Definition: hash.h:228
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:252

Here is the call graph for this function:

Member Data Documentation

template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
TDat TKeyDatFl< TKey, TDat, THashFunc >::Dat
private
template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
TInt TKeyDatFl< TKey, TDat, THashFunc >::ElemCnt
private
template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
TFIn TKeyDatFl< TKey, TDat, THashFunc >::FIn
private
template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
TKey TKeyDatFl< TKey, TDat, THashFunc >::Key
private

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