SNAP Library 2.1, User Reference  2013-09-25 10:47:25
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TKeyDatFl< TKey, TDat, THashFunc > Class Template Reference

#include <shash.h>

List of all members.

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.

: FIn(FNm) { ElemCnt.Load(FIn); }

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.

{ return Dat; }
template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
TDat& TKeyDatFl< TKey, TDat, THashFunc >::GetDat ( ) [inline]

Definition at line 24 of file shash.h.

{ return Dat; }
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.

{ return Key; }
template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
TKey& TKeyDatFl< TKey, TDat, THashFunc >::GetKey ( ) [inline]

Definition at line 22 of file shash.h.

{ return Key; }
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.

{ return ElemCnt; }
template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
static void TKeyDatFl< TKey, TDat, THashFunc >::LoadDatV ( TSIn SIn,
TVec< TDat > &  DatV,
int  LoadN = -1 
) [inline, static]

Definition at line 49 of file shash.h.

                                                                  {
    TInt ElemCnt(SIn);  const int Start=clock();
    if (ElemCnt < LoadN || LoadN == -1) { LoadN = ElemCnt; }
    printf("Loading %s: %d elements ... ", SIn.GetSNm().CStr(), LoadN);  DatV.Gen(LoadN, 0);
    for (int i = 0; i < LoadN; i++) { TKey(SIn);  DatV.Add(TDat(SIn)); }
    printf(" [%ds]\n", int((clock()-Start)/CLOCKS_PER_SEC));
  }
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 
) [inline, static]

Definition at line 33 of file shash.h.

                                                                                                   {
    TFIn FIn(InFNm);  Load(FIn, Hash, LoadN); }
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 
) [inline, static]

Definition at line 35 of file shash.h.

                                                                                    {
    TInt ElemCnt(SIn);  const int Start=clock();
    if (ElemCnt < LoadN || LoadN == -1) { LoadN = ElemCnt; }
    printf("Loading %s: %d elements ... ", SIn.GetSNm().CStr(), LoadN);  Hash.Gen(LoadN);
    for (int i = 0; i < LoadN; i++) { Hash.AddDat(TKey(SIn)).Load(SIn); }
    printf(" [%ds]\n", int((clock()-Start)/CLOCKS_PER_SEC));
  }
template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
static void TKeyDatFl< TKey, TDat, THashFunc >::LoadKeyV ( TSIn SIn,
TVec< TKey > &  KeyV,
int  LoadN = -1 
) [inline, static]

Definition at line 42 of file shash.h.

                                                                  {
    TInt ElemCnt(SIn);  const int Start=clock();
    if (ElemCnt < LoadN || LoadN == -1) { LoadN = ElemCnt; }
    printf("Loading %s: %d elements ... ", SIn.GetSNm().CStr(), LoadN);  KeyV.Gen(LoadN, 0);
    for (int i = 0; i < LoadN; i++) { KeyV.Add(TKey(SIn));  TDat D(SIn); }
    printf(" [%ds]\n", int((clock()-Start)/CLOCKS_PER_SEC));
  }
template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
bool TKeyDatFl< TKey, TDat, THashFunc >::Next ( ) [inline]

Definition at line 19 of file shash.h.

              { if (FIn.Eof()) { return false; }
    Key.Load(FIn);  Dat.Load(FIn); return true; }
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 
) [inline, static]

Definition at line 26 of file shash.h.

                                                                                 {
    TFOut FOut(OutFNm);  Load(FOut, Hash); }
template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
static void TKeyDatFl< TKey, TDat, THashFunc >::Save ( TSOut SOut,
const THash< TKey, TDat, THashFunc > &  Hash 
) [inline, static]

Definition at line 28 of file shash.h.

                                                                          {
    SOut.Save(Hash.Len());
    for (int k = Hash.FFirstKeyId(); Hash.FNextKeyId(k); ) {
      Hash.GetKey(k).Save(SOut);  Hash[k].Save(SOut); }
  }

Member Data Documentation

template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
TDat TKeyDatFl< TKey, TDat, THashFunc >::Dat [private]

Definition at line 15 of file shash.h.

template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
TInt TKeyDatFl< TKey, TDat, THashFunc >::ElemCnt [private]

Definition at line 12 of file shash.h.

template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
TFIn TKeyDatFl< TKey, TDat, THashFunc >::FIn [private]

Definition at line 13 of file shash.h.

template<class TKey , class TDat , class THashFunc = TDefaultHashFunc<TKey>>
TKey TKeyDatFl< TKey, TDat, THashFunc >::Key [private]

Definition at line 14 of file shash.h.


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