SNAP Library 2.2, Developer Reference  2014-03-11 19:15:55
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
TStrHash< TDat, TStringPool, THashFunc > Class Template Reference

#include <hash.h>

Collaboration diagram for TStrHash< TDat, TStringPool, THashFunc >:

List of all members.

Public Member Functions

 TStrHash ()
 TStrHash (const PStringPool &StrPool)
 TStrHash (const int &Ports, const bool &_AutoSizeP=false, const PStringPool &StrPool=PStringPool())
 TStrHash (const TStrHash &Hash)
 TStrHash (TSIn &SIn, bool PoolToo=true)
void Load (TSIn &SIn, bool PoolToo=true)
void Save (TSOut &SOut, bool PoolToo=true) const
void SetPool (const PStringPool &StrPool)
PStringPool GetPool () const
TStrHashoperator= (const TStrHash &Hash)
bool Empty () const
int Len () const
int Reserved () const
int GetPorts () const
bool IsAutoSize () const
int GetMxKeyIds () const
bool IsKeyIdEqKeyN () const
int AddKey (const char *Key)
int AddKey (const TStr &Key)
int AddKey (const TChA &Key)
int AddDat (const char *Key, const TDat &Dat)
int AddDat (const TStr &Key, const TDat &Dat)
int AddDat (const TChA &Key, const TDat &Dat)
TDat & AddDat (const char *Key)
TDat & AddDat (const TStr &Key)
TDat & AddDat (const TChA &Key)
TDat & AddDatId (const char *Key)
TDat & AddDatId (const TStr &Key)
TDat & AddDatId (const TChA &Key)
const TDat & operator[] (const int &KeyId) const
TDat & operator[] (const int &KeyId)
const TDat & operator() (const char *Key) const
const TDat & GetDat (const char *Key) const
const TDat & GetDat (const TStr &Key) const
TDat & GetDat (const char *Key)
const TDat & GetDat (const TStr &Key)
const TDat & GetDat (const TChA &Key)
TDat & GetDatId (const int &KeyId)
const TDat & GetDatId (const int &KeyId) const
void GetKeyDat (const int &KeyId, int &KeyO, TDat &Dat) const
void GetKeyDat (const int &KeyId, const char *&Key, TDat &Dat) const
void GetKeyDat (const int &KeyId, TStr &Key, TDat &Dat) const
void GetKeyDat (const int &KeyId, TChA &Key, TDat &Dat) const
int GetKeyId (const char *Key) const
int GetKeyId (const TStr &Key) const
const char * GetKey (const int &KeyId) const
int GetKeyOfs (const int &KeyId) const
const char * KeyFromOfs (const int &KeyO) const
bool IsKey (const char *Key) const
bool IsKey (const TStr &Key) const
bool IsKey (const TChA &Key) const
bool IsKey (const char *Key, int &KeyId) const
bool IsKeyGetDat (const char *Key, TDat &Dat) const
bool IsKeyGetDat (const TStr &Key, TDat &Dat) const
bool IsKeyGetDat (const TChA &Key, TDat &Dat) const
bool IsKeyId (const int &KeyId) const
int FFirstKeyId () const
bool FNextKeyId (int &KeyId) const
void GetKeyV (TVec< TStr > &KeyV) const
void GetStrIdV (TIntV &StrIdV) const
void GetDatV (TVec< TDat > &DatV) const
void GetKeyDatPrV (TVec< TPair< TStr, TDat > > &KeyDatPrV) const
void GetDatKeyPrV (TVec< TPair< TDat, TStr > > &DatKeyPrV) const
void Pack ()

Private Types

typedef TPt< TStringPool > PStringPool
typedef THashKeyDat< TInt, TDat > THKeyDat
typedef TPair< TInt, TDat > TKeyDatP
typedef TVec< THKeyDatTHKeyDatV

Private Member Functions

uint GetNextPrime (const uint &Val) const
void Resize ()
const THKeyDatGetHashKeyDat (const int &KeyId) const
THKeyDatGetHashKeyDat (const int &KeyId)

Private Attributes

TIntV PortV
THKeyDatV KeyDatV
TBool AutoSizeP
TInt FFreeKeyId
TInt FreeKeys
PStringPool Pool

Detailed Description

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
class TStrHash< TDat, TStringPool, THashFunc >

Definition at line 715 of file hash.h.


Member Typedef Documentation

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
typedef TPt<TStringPool> TStrHash< TDat, TStringPool, THashFunc >::PStringPool [private]

Definition at line 718 of file hash.h.

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
typedef THashKeyDat<TInt, TDat> TStrHash< TDat, TStringPool, THashFunc >::THKeyDat [private]

Definition at line 719 of file hash.h.

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
typedef TVec<THKeyDat> TStrHash< TDat, TStringPool, THashFunc >::THKeyDatV [private]

Definition at line 721 of file hash.h.

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
typedef TPair<TInt, TDat> TStrHash< TDat, TStringPool, THashFunc >::TKeyDatP [private]

Definition at line 720 of file hash.h.


Constructor & Destructor Documentation

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TStrHash< TDat, TStringPool, THashFunc >::TStrHash ( ) [inline]

Definition at line 735 of file hash.h.

: PortV(), KeyDatV(), AutoSizeP(true), FFreeKeyId(-1), FreeKeys(0), Pool() { }
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TStrHash< TDat, TStringPool, THashFunc >::TStrHash ( const PStringPool StrPool) [inline]

Definition at line 736 of file hash.h.

: PortV(), KeyDatV(), AutoSizeP(true), FFreeKeyId(-1), FreeKeys(0), Pool(StrPool) { }
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TStrHash< TDat, TStringPool, THashFunc >::TStrHash ( const int &  Ports,
const bool &  _AutoSizeP = false,
const PStringPool StrPool = PStringPool() 
) [inline]

Definition at line 737 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::PortV, and TVec< TVal, TSizeTy >::PutAll().

                                                                                                         :
    PortV(Ports), KeyDatV(Ports, 0), AutoSizeP(_AutoSizeP), FFreeKeyId(-1), FreeKeys(0), Pool(StrPool) { PortV.PutAll(-1); }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TStrHash< TDat, TStringPool, THashFunc >::TStrHash ( const TStrHash< TDat, TStringPool, THashFunc > &  Hash) [inline]

Definition at line 739 of file hash.h.

References TPt< TRec >::Empty(), and TStrHash< TDat, TStringPool, THashFunc >::Pool.

                                : PortV(Hash.PortV), KeyDatV(Hash.KeyDatV), AutoSizeP(Hash.AutoSizeP),
    FFreeKeyId(Hash.FFreeKeyId), FreeKeys(Hash.FreeKeys), Pool() {
      if (! Hash.Pool.Empty()) { Pool=PStringPool(new TStringPool(*Hash.Pool)); } }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TStrHash< TDat, TStringPool, THashFunc >::TStrHash ( TSIn SIn,
bool  PoolToo = true 
) [inline]

Definition at line 742 of file hash.h.

References TSIn::LoadCs(), and TStrHash< TDat, TStringPool, THashFunc >::Pool.

: PortV(SIn), KeyDatV(SIn), AutoSizeP(SIn), FFreeKeyId(SIn), FreeKeys(SIn){ SIn.LoadCs(); if (PoolToo) Pool = PStringPool(SIn); }

Here is the call graph for this function:


Member Function Documentation

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
int TStrHash< TDat, TStringPool, THashFunc >::AddDat ( const char *  Key,
const TDat &  Dat 
) [inline]

Definition at line 765 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

{ const int KeyId = AddKey(Key); KeyDatV[KeyId].Dat = Dat; return KeyId; }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
int TStrHash< TDat, TStringPool, THashFunc >::AddDat ( const TStr Key,
const TDat &  Dat 
) [inline]

Definition at line 766 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), TStr::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

{ const int KeyId = AddKey(Key.CStr()); KeyDatV[KeyId].Dat = Dat; return KeyId; }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
int TStrHash< TDat, TStringPool, THashFunc >::AddDat ( const TChA Key,
const TDat &  Dat 
) [inline]

Definition at line 767 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), TChA::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

{ const int KeyId = AddKey(Key.CStr()); KeyDatV[KeyId].Dat = Dat; return KeyId; }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDat ( const char *  Key) [inline]

Definition at line 768 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

{ return KeyDatV[AddKey(Key)].Dat; }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDat ( const TStr Key) [inline]

Definition at line 769 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), TStr::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

{ return KeyDatV[AddKey(Key.CStr())].Dat; }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDat ( const TChA Key) [inline]

Definition at line 770 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), TChA::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

{ return KeyDatV[AddKey(Key.CStr())].Dat; }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDatId ( const char *  Key) [inline]

Definition at line 771 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

Referenced by TSnap::LoadConnListStr().

{ const int KeyId = AddKey(Key);  return KeyDatV[KeyId].Dat = KeyId; }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDatId ( const TStr Key) [inline]

Definition at line 772 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), TStr::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

{ const int KeyId = AddKey(Key.CStr());  return KeyDatV[KeyId].Dat = KeyId; }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDatId ( const TChA Key) [inline]

Definition at line 773 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), TChA::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

{ const int KeyId = AddKey(Key.CStr());  return KeyDatV[KeyId].Dat = KeyId; }

Here is the call graph for this function:

template<class TDat , class TStringPool , class THashFunc >
int TStrHash< TDat, TStringPool, THashFunc >::AddKey ( const char *  Key)

Definition at line 869 of file hash.h.

Referenced by TStrHash< TDat, TStringPool, THashFunc >::AddDat(), TStrHash< TDat, TStringPool, THashFunc >::AddDatId(), TCoda::DumpMemberships(), TSnap::LoadEdgeListStr(), TAGMUtil::LoadEdgeListStr(), and TTimeNENet::LoadEdgeTm().

                                                                  {
  if (Pool.Empty()) Pool = TStringPool::New();
  if ((AutoSizeP && KeyDatV.Len() > PortV.Len()) || PortV.Empty()) Resize();
  const int PortN = abs(THashFunc::GetPrimHashCd(Key) % PortV.Len());
  const int HashCd = abs(THashFunc::GetSecHashCd(Key));
  int PrevKeyId = -1;
  int KeyId = PortV[PortN];
  while (KeyId != -1 && ! (KeyDatV[KeyId].HashCd == HashCd && Pool->Cmp(KeyDatV[KeyId].Key, Key) == 0)) {
    PrevKeyId = KeyId;  KeyId = KeyDatV[KeyId].Next; }
  if (KeyId == -1) {
    const int StrId = Pool->AddStr(Key);
    if (FFreeKeyId == -1) {
      KeyId = KeyDatV.Add(THKeyDat(-1, HashCd, StrId));
    } else {
      KeyId = FFreeKeyId;
      FFreeKeyId = KeyDatV[FFreeKeyId].Next;
      FreeKeys--;
      KeyDatV[KeyId] = THKeyDat(-1, HashCd, StrId);
    }
    if (PrevKeyId == -1) PortV[PortN] = KeyId;
    else KeyDatV[PrevKeyId].Next = KeyId;
  }
  return KeyId;
}

Here is the caller graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
int TStrHash< TDat, TStringPool, THashFunc >::AddKey ( const TStr Key) [inline]

Definition at line 763 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), and TStr::CStr().

Referenced by TStrHash< TDat, TStringPool, THashFunc >::AddKey().

{ return AddKey(Key.CStr()); }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
int TStrHash< TDat, TStringPool, THashFunc >::AddKey ( const TChA Key) [inline]

Definition at line 764 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), and TChA::CStr().

Referenced by TStrHash< TDat, TStringPool, THashFunc >::AddKey().

{ return AddKey(Key.CStr()); }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
bool TStrHash< TDat, TStringPool, THashFunc >::Empty ( ) const [inline]

Definition at line 754 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::Len().

{return ! Len(); }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
int TStrHash< TDat, TStringPool, THashFunc >::FFirstKeyId ( ) const [inline]

Definition at line 807 of file hash.h.

{return 0-1;}
template<class TDat , class TStringPool , class THashFunc >
bool TStrHash< TDat, TStringPool, THashFunc >::FNextKeyId ( int &  KeyId) const

Definition at line 906 of file hash.h.

                                                                        {
  do KeyId++; while (KeyId < KeyDatV.Len() && KeyDatV[KeyId].HashCd == -1);
  return KeyId < KeyDatV.Len();
}
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
const TDat& TStrHash< TDat, TStringPool, THashFunc >::GetDat ( const char *  Key) const [inline]

Definition at line 780 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::GetKeyId(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

Referenced by TStrHash< TDat, TStringPool, THashFunc >::operator()().

{ return KeyDatV[GetKeyId(Key)].Dat; }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
const TDat& TStrHash< TDat, TStringPool, THashFunc >::GetDat ( const TStr Key) const [inline]

Definition at line 781 of file hash.h.

References TStr::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::GetDat().

Referenced by TStrHash< TDat, TStringPool, THashFunc >::GetDat().

{ return GetDat(Key.CStr()); }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TDat& TStrHash< TDat, TStringPool, THashFunc >::GetDat ( const char *  Key) [inline]

Definition at line 782 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::GetKeyId(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

{ return KeyDatV[GetKeyId(Key)].Dat; }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
const TDat& TStrHash< TDat, TStringPool, THashFunc >::GetDat ( const TStr Key) [inline]

Definition at line 783 of file hash.h.

References TStr::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::GetDat().

Referenced by TStrHash< TDat, TStringPool, THashFunc >::GetDat().

{ return GetDat(Key.CStr()); }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
const TDat& TStrHash< TDat, TStringPool, THashFunc >::GetDat ( const TChA Key) [inline]

Definition at line 784 of file hash.h.

References TChA::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::GetDat().

Referenced by TStrHash< TDat, TStringPool, THashFunc >::GetDat().

{ return GetDat(Key.CStr()); }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TDat& TStrHash< TDat, TStringPool, THashFunc >::GetDatId ( const int &  KeyId) [inline]

Definition at line 785 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

{ return KeyDatV[KeyId].Dat; }
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
const TDat& TStrHash< TDat, TStringPool, THashFunc >::GetDatId ( const int &  KeyId) const [inline]

Definition at line 786 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

{ return KeyDatV[KeyId].Dat; }
template<class TDat , class TStringPool , class THashFunc >
void TStrHash< TDat, TStringPool, THashFunc >::GetDatKeyPrV ( TVec< TPair< TDat, TStr > > &  DatKeyPrV) const

Definition at line 947 of file hash.h.

                                                                                                   {
  DatKeyPrV.Gen(Len(), 0);
  TStr Str; TDat Dat;
  int KeyId = FFirstKeyId();
  while (FNextKeyId(KeyId)){
    GetKeyDat(KeyId, Str, Dat);
    DatKeyPrV.Add(TPair<TDat, TStr>(Dat, Str));
  }
}
template<class TDat , class TStringPool , class THashFunc >
void TStrHash< TDat, TStringPool, THashFunc >::GetDatV ( TVec< TDat > &  DatV) const

Definition at line 928 of file hash.h.

References TVec< TVal, TSizeTy >::Add(), and TVec< TVal, TSizeTy >::Gen().

                                                                           {
  DatV.Gen(Len(), 0);
  int KeyId = FFirstKeyId();
  while (FNextKeyId(KeyId))
    DatV.Add(GetHashKeyDat(KeyId).Dat);
}

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
const THKeyDat& TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat ( const int &  KeyId) const [inline, private]
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
THKeyDat& TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat ( const int &  KeyId) [inline, private]

Definition at line 732 of file hash.h.

References Assert, THashKeyDat< TKey, TDat >::HashCd, and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

                                            {
    THKeyDat& KeyDat = KeyDatV[KeyId];  Assert(KeyDat.HashCd != -1);  return KeyDat; }
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
const char* TStrHash< TDat, TStringPool, THashFunc >::GetKey ( const int &  KeyId) const [inline]

Definition at line 794 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat(), and TStrHash< TDat, TStringPool, THashFunc >::Pool.

Referenced by TCesna::DisplayAttrs(), TCoda::DumpMemberships(), TCesnaUtil::DumpNIDAttrHToNIDK(), and TAGMUtil::LoadEdgeListStr().

{ return Pool->GetCStr(GetHashKeyDat(KeyId).Key); }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
void TStrHash< TDat, TStringPool, THashFunc >::GetKeyDat ( const int &  KeyId,
int &  KeyO,
TDat &  Dat 
) const [inline]

Definition at line 787 of file hash.h.

References THashKeyDat< TKey, TDat >::Dat, TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat(), and THashKeyDat< TKey, TDat >::Key.

{ const THKeyDat& KeyDat = GetHashKeyDat(KeyId); KeyO = KeyDat.Key; Dat = KeyDat.Dat; }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
void TStrHash< TDat, TStringPool, THashFunc >::GetKeyDat ( const int &  KeyId,
const char *&  Key,
TDat &  Dat 
) const [inline]

Definition at line 788 of file hash.h.

References THashKeyDat< TKey, TDat >::Dat, TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat(), THashKeyDat< TKey, TDat >::Key, and TStrHash< TDat, TStringPool, THashFunc >::KeyFromOfs().

{ const THKeyDat& KeyDat = GetHashKeyDat(KeyId); Key = KeyFromOfs(KeyDat.Key); Dat = KeyDat.Dat; }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
void TStrHash< TDat, TStringPool, THashFunc >::GetKeyDat ( const int &  KeyId,
TStr Key,
TDat &  Dat 
) const [inline]

Definition at line 789 of file hash.h.

References THashKeyDat< TKey, TDat >::Dat, TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat(), THashKeyDat< TKey, TDat >::Key, and TStrHash< TDat, TStringPool, THashFunc >::KeyFromOfs().

{ const THKeyDat& KeyDat = GetHashKeyDat(KeyId); Key = KeyFromOfs(KeyDat.Key); Dat = KeyDat.Dat;}

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
void TStrHash< TDat, TStringPool, THashFunc >::GetKeyDat ( const int &  KeyId,
TChA Key,
TDat &  Dat 
) const [inline]

Definition at line 790 of file hash.h.

References THashKeyDat< TKey, TDat >::Dat, TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat(), THashKeyDat< TKey, TDat >::Key, and TStrHash< TDat, TStringPool, THashFunc >::KeyFromOfs().

{ const THKeyDat& KeyDat = GetHashKeyDat(KeyId); Key = KeyFromOfs(KeyDat.Key); Dat = KeyDat.Dat;}

Here is the call graph for this function:

template<class TDat , class TStringPool , class THashFunc >
void TStrHash< TDat, TStringPool, THashFunc >::GetKeyDatPrV ( TVec< TPair< TStr, TDat > > &  KeyDatPrV) const

Definition at line 936 of file hash.h.

                                                                                                   {
  KeyDatPrV.Gen(Len(), 0);
  TStr Str; TDat Dat;
  int KeyId = FFirstKeyId();
  while (FNextKeyId(KeyId)){
    GetKeyDat(KeyId, Str, Dat);
    KeyDatPrV.Add(TPair<TStr, TDat>(Str, Dat));
  }
}
template<class TDat , class TStringPool , class THashFunc >
int TStrHash< TDat, TStringPool, THashFunc >::GetKeyId ( const char *  Key) const

Definition at line 895 of file hash.h.

Referenced by TStrHash< TDat, TStringPool, THashFunc >::GetDat(), TStrHash< TDat, TStringPool, THashFunc >::IsKey(), TStrHash< TDat, TStringPool, THashFunc >::IsKeyGetDat(), TAGMUtil::LoadCmtyVV(), and TCesnaUtil::LoadNIDAttrHFromNIDKH().

                                                                          {
  if (PortV.Empty()) return -1;
  const int PortN = abs(THashFunc::GetPrimHashCd(Key) % PortV.Len());
  const int Hc = abs(THashFunc::GetSecHashCd(Key));
  int KeyId = PortV[PortN];
  while (KeyId != -1 && ! (KeyDatV[KeyId].HashCd == Hc && Pool->Cmp(KeyDatV[KeyId].Key, Key) == 0))
    KeyId = KeyDatV[KeyId].Next;
  return KeyId;
}

Here is the caller graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
int TStrHash< TDat, TStringPool, THashFunc >::GetKeyId ( const TStr Key) const [inline]

Definition at line 793 of file hash.h.

References TStr::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::GetKeyId().

Referenced by TStrHash< TDat, TStringPool, THashFunc >::GetKeyId().

{ return GetKeyId(Key.CStr()); }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
int TStrHash< TDat, TStringPool, THashFunc >::GetKeyOfs ( const int &  KeyId) const [inline]

Definition at line 795 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat(), and THashKeyDat< TKey, TDat >::Key.

{ return GetHashKeyDat(KeyId).Key; } // pool string id

Here is the call graph for this function:

template<class TDat , class TStringPool , class THashFunc >
void TStrHash< TDat, TStringPool, THashFunc >::GetKeyV ( TVec< TStr > &  KeyV) const

Definition at line 912 of file hash.h.

References TVec< TVal, TSizeTy >::Add(), and TVec< TVal, TSizeTy >::Gen().

                                                                           {
  KeyV.Gen(Len(), 0);
  int KeyId = FFirstKeyId();
  while (FNextKeyId(KeyId))
    KeyV.Add(GetKey(KeyId));
}

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
int TStrHash< TDat, TStringPool, THashFunc >::GetMxKeyIds ( ) const [inline]

Definition at line 759 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::KeyDatV, and TVec< TVal, TSizeTy >::Len().

{ return KeyDatV.Len(); }

Here is the call graph for this function:

template<class TDat , class TStringPool , class THashFunc >
uint TStrHash< TDat, TStringPool, THashFunc >::GetNextPrime ( const uint Val) const [private]

Definition at line 820 of file hash.h.

References THash< TInt, TInt >::HashPrimes, and THash< TInt, TInt >::HashPrimeT.

                                                                               {
  uint *f = (uint *) TIntH::HashPrimeT, *m, *l = (uint *) TIntH::HashPrimeT + (int) TIntH::HashPrimes;
  int h, len = (int)TIntH::HashPrimes;
  while (len > 0) {
    h = len >> 1;  m = f + h;
    if (*m < Val) { f = m;  f++;  len = len - h - 1; }
    else len = h;
  }
  return f == l ? *(l - 1) : *f;
}
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
PStringPool TStrHash< TDat, TStringPool, THashFunc >::GetPool ( ) const [inline]

Definition at line 750 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::Pool.

{ return Pool; }
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
int TStrHash< TDat, TStringPool, THashFunc >::GetPorts ( ) const [inline]

Definition at line 757 of file hash.h.

References TVec< TVal, TSizeTy >::Len(), and TStrHash< TDat, TStringPool, THashFunc >::PortV.

{ return PortV.Len(); }

Here is the call graph for this function:

template<class TDat , class TStringPool , class THashFunc >
void TStrHash< TDat, TStringPool, THashFunc >::GetStrIdV ( TIntV StrIdV) const

Definition at line 920 of file hash.h.

References TVec< TVal, TSizeTy >::Add(), and TVec< TVal, TSizeTy >::Gen().

                                                                          {
  StrIdV.Gen(Len(), 0);
  int KeyId = FFirstKeyId();
  while (FNextKeyId(KeyId))
    StrIdV.Add(GetKeyOfs(KeyId));
}

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
bool TStrHash< TDat, TStringPool, THashFunc >::IsAutoSize ( ) const [inline]

Definition at line 758 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::AutoSizeP.

{ return AutoSizeP; }
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
bool TStrHash< TDat, TStringPool, THashFunc >::IsKey ( const char *  Key) const [inline]

Definition at line 798 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::GetKeyId().

Referenced by TStrUtil::CountWords(), TAGMUtil::LoadCmtyVV(), and TCesnaUtil::LoadNIDAttrHFromNIDKH().

{ return GetKeyId(Key) != -1; }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
bool TStrHash< TDat, TStringPool, THashFunc >::IsKey ( const TStr Key) const [inline]

Definition at line 799 of file hash.h.

References TStr::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::GetKeyId().

{ return GetKeyId(Key.CStr()) != -1; }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
bool TStrHash< TDat, TStringPool, THashFunc >::IsKey ( const TChA Key) const [inline]

Definition at line 800 of file hash.h.

References TChA::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::GetKeyId().

{ return GetKeyId(Key.CStr()) != -1; }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
bool TStrHash< TDat, TStringPool, THashFunc >::IsKey ( const char *  Key,
int &  KeyId 
) const [inline]

Definition at line 801 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::GetKeyId().

{ KeyId = GetKeyId(Key); return KeyId != -1; }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
bool TStrHash< TDat, TStringPool, THashFunc >::IsKeyGetDat ( const char *  Key,
TDat &  Dat 
) const [inline]

Definition at line 802 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::GetKeyId(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

{ const int KeyId = GetKeyId(Key); if (KeyId != -1) { Dat = KeyDatV[KeyId].Dat; return true; } else return false; }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
bool TStrHash< TDat, TStringPool, THashFunc >::IsKeyGetDat ( const TStr Key,
TDat &  Dat 
) const [inline]

Definition at line 803 of file hash.h.

References TStr::CStr(), TStrHash< TDat, TStringPool, THashFunc >::GetKeyId(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

{ const int KeyId = GetKeyId(Key.CStr()); if (KeyId != -1) { Dat = KeyDatV[KeyId].Dat; return true; } else return false; }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
bool TStrHash< TDat, TStringPool, THashFunc >::IsKeyGetDat ( const TChA Key,
TDat &  Dat 
) const [inline]

Definition at line 804 of file hash.h.

References TChA::CStr(), TStrHash< TDat, TStringPool, THashFunc >::GetKeyId(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.

{ const int KeyId = GetKeyId(Key.CStr()); if (KeyId != -1) { Dat = KeyDatV[KeyId].Dat; return true; } else return false; }

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
bool TStrHash< TDat, TStringPool, THashFunc >::IsKeyId ( const int &  KeyId) const [inline]

Definition at line 805 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::KeyDatV, and TVec< TVal, TSizeTy >::Len().

Referenced by TCesnaUtil::DumpNIDAttrHToNIDK().

{ return 0 <= KeyId && KeyId < KeyDatV.Len() && KeyDatV[KeyId].HashCd != -1; }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
bool TStrHash< TDat, TStringPool, THashFunc >::IsKeyIdEqKeyN ( ) const [inline]

Definition at line 760 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::FreeKeys.

{return ! FreeKeys; }
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
const char* TStrHash< TDat, TStringPool, THashFunc >::KeyFromOfs ( const int &  KeyO) const [inline]

Definition at line 796 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::Pool.

Referenced by TStrHash< TDat, TStringPool, THashFunc >::GetKeyDat().

{ return Pool->GetCStr(KeyO); }

Here is the caller graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
int TStrHash< TDat, TStringPool, THashFunc >::Len ( ) const [inline]
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
void TStrHash< TDat, TStringPool, THashFunc >::Load ( TSIn SIn,
bool  PoolToo = true 
) [inline]
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
const TDat& TStrHash< TDat, TStringPool, THashFunc >::operator() ( const char *  Key) const [inline]

Definition at line 777 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::GetDat().

{ return GetDat(Key);}

Here is the call graph for this function:

template<class TDat , class TStringPool , class THashFunc >
TStrHash< TDat, TStringPool, THashFunc > & TStrHash< TDat, TStringPool, THashFunc >::operator= ( const TStrHash< TDat, TStringPool, THashFunc > &  Hash)
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
const TDat& TStrHash< TDat, TStringPool, THashFunc >::operator[] ( const int &  KeyId) const [inline]

Definition at line 775 of file hash.h.

References THashKeyDat< TKey, TDat >::Dat, and TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat().

{return GetHashKeyDat(KeyId).Dat;}

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TDat& TStrHash< TDat, TStringPool, THashFunc >::operator[] ( const int &  KeyId) [inline]

Definition at line 776 of file hash.h.

References THashKeyDat< TKey, TDat >::Dat, and TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat().

{return GetHashKeyDat(KeyId).Dat;}

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
void TStrHash< TDat, TStringPool, THashFunc >::Pack ( ) [inline]

Definition at line 816 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::KeyDatV, and TVec< TVal, TSizeTy >::Pack().

Here is the call graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
int TStrHash< TDat, TStringPool, THashFunc >::Reserved ( ) const [inline]

Definition at line 756 of file hash.h.

References TStrHash< TDat, TStringPool, THashFunc >::KeyDatV, and TVec< TVal, TSizeTy >::Reserved().

{ return KeyDatV.Reserved(); }

Here is the call graph for this function:

template<class TDat , class TStringPool , class THashFunc >
void TStrHash< TDat, TStringPool, THashFunc >::Resize ( ) [private]

Definition at line 832 of file hash.h.

References THashKeyDat< TKey, TDat >::HashCd, THashKeyDat< TKey, TDat >::Key, and THashKeyDat< TKey, TDat >::Next.

                                                    {
  // resize & initialize port vector
  if (PortV.Empty()) { PortV.Gen(17);  PortV.PutAll(-1); }
  else
  if (AutoSizeP && KeyDatV.Len() > 3 * PortV.Len()) {
    const int NxPrime = GetNextPrime(KeyDatV.Len());
    //printf("%s resize PortV: %d -> %d, Len: %d\n", GetTypeNm(*this).CStr(), PortV.Len(), NxPrime, Len());
    PortV.Gen(NxPrime);  PortV.PutAll(-1); }
  else
    return;
  // rehash keys
  const int NPorts = PortV.Len();
  for (int i = 0; i < KeyDatV.Len(); i++) {
    THKeyDat& KeyDat = KeyDatV[i];
    if (KeyDat.HashCd != -1) {
      const int Port = abs(THashFunc::GetPrimHashCd(Pool->GetCStr(KeyDat.Key)) % NPorts);
      KeyDat.Next = PortV[Port];
      PortV[Port] = i;
    }
  }
}
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
void TStrHash< TDat, TStringPool, THashFunc >::Save ( TSOut SOut,
bool  PoolToo = true 
) const [inline]
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
void TStrHash< TDat, TStringPool, THashFunc >::SetPool ( const PStringPool StrPool) [inline]

Definition at line 749 of file hash.h.

References TPt< TRec >::Empty(), IAssert, and TStrHash< TDat, TStringPool, THashFunc >::Pool.

{ IAssert(Pool.Empty() || Pool->Empty()); Pool = StrPool; }

Here is the call graph for this function:


Member Data Documentation

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TBool TStrHash< TDat, TStringPool, THashFunc >::AutoSizeP [private]
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TInt TStrHash< TDat, TStringPool, THashFunc >::FFreeKeyId [private]
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TInt TStrHash< TDat, TStringPool, THashFunc >::FreeKeys [private]
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TIntV TStrHash< TDat, TStringPool, THashFunc >::PortV [private]

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