SNAP Library , Developer Reference
2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <hash.h>
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 |
TStrHash & | operator= (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< THKeyDat > | THKeyDatV |
Private Member Functions | |
uint | GetNextPrime (const uint &Val) const |
void | Resize () |
const THKeyDat & | GetHashKeyDat (const int &KeyId) const |
THKeyDat & | GetHashKeyDat (const int &KeyId) |
Private Attributes | |
TIntV | PortV |
THKeyDatV | KeyDatV |
TBool | AutoSizeP |
TInt | FFreeKeyId |
TInt | FreeKeys |
PStringPool | Pool |
typedef TPt<TStringPool> TStrHash< TDat, TStringPool, THashFunc >::PStringPool [private] |
typedef THashKeyDat<TInt, TDat> TStrHash< TDat, TStringPool, THashFunc >::THKeyDat [private] |
TStrHash< TDat, TStringPool, THashFunc >::TStrHash | ( | const PStringPool & | StrPool | ) | [inline] |
TStrHash< TDat, TStringPool, THashFunc >::TStrHash | ( | const int & | Ports, |
const bool & | _AutoSizeP = false , |
||
const PStringPool & | StrPool = PStringPool() |
||
) | [inline] |
Definition at line 735 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::PortV, and TVec< TVal >::PutAll().
: PortV(Ports), KeyDatV(Ports, 0), AutoSizeP(_AutoSizeP), FFreeKeyId(-1), FreeKeys(0), Pool(StrPool) { PortV.PutAll(-1); }
TStrHash< TDat, TStringPool, THashFunc >::TStrHash | ( | const TStrHash< TDat, TStringPool, THashFunc > & | Hash | ) | [inline] |
Definition at line 737 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)); } }
TStrHash< TDat, TStringPool, THashFunc >::TStrHash | ( | TSIn & | SIn, |
bool | PoolToo = true |
||
) | [inline] |
Definition at line 740 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); }
int TStrHash< TDat, TStringPool, THashFunc >::AddDat | ( | const char * | Key, |
const TDat & | Dat | ||
) | [inline] |
Definition at line 763 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.
int TStrHash< TDat, TStringPool, THashFunc >::AddDat | ( | const TStr & | Key, |
const TDat & | Dat | ||
) | [inline] |
Definition at line 764 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), TStr::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.
int TStrHash< TDat, TStringPool, THashFunc >::AddDat | ( | const TChA & | Key, |
const TDat & | Dat | ||
) | [inline] |
Definition at line 765 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), TChA::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDat | ( | const char * | Key | ) | [inline] |
Definition at line 766 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDat | ( | const TStr & | Key | ) | [inline] |
Definition at line 767 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), TStr::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDat | ( | const TChA & | Key | ) | [inline] |
Definition at line 768 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), TChA::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDatId | ( | const char * | Key | ) | [inline] |
Definition at line 769 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.
Referenced by TSnap::LoadConnListStr().
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDatId | ( | const TStr & | Key | ) | [inline] |
Definition at line 770 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), TStr::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDatId | ( | const TChA & | Key | ) | [inline] |
Definition at line 771 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), TChA::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.
int TStrHash< TDat, TStringPool, THashFunc >::AddKey | ( | const char * | Key | ) |
Definition at line 867 of file hash.h.
Referenced by TStrHash< TDat, TStringPool, THashFunc >::AddDat(), TStrHash< TDat, TStringPool, THashFunc >::AddDatId(), TSnap::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; }
int TStrHash< TDat, TStringPool, THashFunc >::AddKey | ( | const TStr & | Key | ) | [inline] |
Definition at line 761 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), and TStr::CStr().
Referenced by TStrHash< TDat, TStringPool, THashFunc >::AddKey().
int TStrHash< TDat, TStringPool, THashFunc >::AddKey | ( | const TChA & | Key | ) | [inline] |
Definition at line 762 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::AddKey(), and TChA::CStr().
Referenced by TStrHash< TDat, TStringPool, THashFunc >::AddKey().
bool TStrHash< TDat, TStringPool, THashFunc >::Empty | ( | ) | const [inline] |
Definition at line 752 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::Len().
{return ! Len(); }
int TStrHash< TDat, TStringPool, THashFunc >::FFirstKeyId | ( | ) | const [inline] |
bool TStrHash< TDat, TStringPool, THashFunc >::FNextKeyId | ( | int & | KeyId | ) | const |
const TDat& TStrHash< TDat, TStringPool, THashFunc >::GetDat | ( | const char * | Key | ) | const [inline] |
Definition at line 778 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::GetKeyId(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.
Referenced by TStrHash< TDat, TStringPool, THashFunc >::operator()().
const TDat& TStrHash< TDat, TStringPool, THashFunc >::GetDat | ( | const TStr & | Key | ) | const [inline] |
Definition at line 779 of file hash.h.
References TStr::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::GetDat().
Referenced by TStrHash< TDat, TStringPool, THashFunc >::GetDat().
TDat& TStrHash< TDat, TStringPool, THashFunc >::GetDat | ( | const char * | Key | ) | [inline] |
Definition at line 780 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::GetKeyId(), and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.
const TDat& TStrHash< TDat, TStringPool, THashFunc >::GetDat | ( | const TStr & | Key | ) | [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().
const TDat& TStrHash< TDat, TStringPool, THashFunc >::GetDat | ( | const TChA & | Key | ) | [inline] |
Definition at line 782 of file hash.h.
References TChA::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::GetDat().
Referenced by TStrHash< TDat, TStringPool, THashFunc >::GetDat().
TDat& TStrHash< TDat, TStringPool, THashFunc >::GetDatId | ( | const int & | KeyId | ) | [inline] |
Definition at line 783 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.
{ return KeyDatV[KeyId].Dat; }
const TDat& TStrHash< TDat, TStringPool, THashFunc >::GetDatId | ( | const int & | KeyId | ) | const [inline] |
Definition at line 784 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.
{ return KeyDatV[KeyId].Dat; }
void TStrHash< TDat, TStringPool, THashFunc >::GetDatKeyPrV | ( | TVec< TPair< TDat, TStr > > & | DatKeyPrV | ) | const |
Definition at line 945 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)); } }
void TStrHash< TDat, TStringPool, THashFunc >::GetDatV | ( | TVec< TDat > & | DatV | ) | const |
Definition at line 926 of file hash.h.
References TVec< TVal >::Add(), and TVec< TVal >::Gen().
{ DatV.Gen(Len(), 0); int KeyId = FFirstKeyId(); while (FNextKeyId(KeyId)) DatV.Add(GetHashKeyDat(KeyId).Dat); }
const THKeyDat& TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat | ( | const int & | KeyId | ) | const [inline, private] |
Definition at line 728 of file hash.h.
References Assert, THashKeyDat< TKey, TDat >::HashCd, and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.
Referenced by TStrHash< TDat, TStringPool, THashFunc >::GetKey(), TStrHash< TDat, TStringPool, THashFunc >::GetKeyDat(), TStrHash< TDat, TStringPool, THashFunc >::GetKeyOfs(), and TStrHash< TDat, TStringPool, THashFunc >::operator[]().
THKeyDat& TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat | ( | const int & | KeyId | ) | [inline, private] |
Definition at line 730 of file hash.h.
References Assert, THashKeyDat< TKey, TDat >::HashCd, and TStrHash< TDat, TStringPool, THashFunc >::KeyDatV.
const char* TStrHash< TDat, TStringPool, THashFunc >::GetKey | ( | const int & | KeyId | ) | const [inline] |
Definition at line 792 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat(), and TStrHash< TDat, TStringPool, THashFunc >::Pool.
{ return Pool->GetCStr(GetHashKeyDat(KeyId).Key); }
void TStrHash< TDat, TStringPool, THashFunc >::GetKeyDat | ( | const int & | KeyId, |
int & | KeyO, | ||
TDat & | Dat | ||
) | const [inline] |
Definition at line 785 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; }
void TStrHash< TDat, TStringPool, THashFunc >::GetKeyDat | ( | const int & | KeyId, |
const char *& | Key, | ||
TDat & | Dat | ||
) | const [inline] |
Definition at line 786 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; }
void TStrHash< TDat, TStringPool, THashFunc >::GetKeyDat | ( | const int & | KeyId, |
TStr & | Key, | ||
TDat & | Dat | ||
) | const [inline] |
Definition at line 787 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;}
void TStrHash< TDat, TStringPool, THashFunc >::GetKeyDat | ( | const int & | KeyId, |
TChA & | 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;}
void TStrHash< TDat, TStringPool, THashFunc >::GetKeyDatPrV | ( | TVec< TPair< TStr, TDat > > & | KeyDatPrV | ) | const |
Definition at line 934 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)); } }
int TStrHash< TDat, TStringPool, THashFunc >::GetKeyId | ( | const char * | Key | ) | const |
Definition at line 893 of file hash.h.
Referenced by TStrHash< TDat, TStringPool, THashFunc >::GetDat(), TStrHash< TDat, TStringPool, THashFunc >::IsKey(), and TStrHash< TDat, TStringPool, THashFunc >::IsKeyGetDat().
{ 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; }
int TStrHash< TDat, TStringPool, THashFunc >::GetKeyId | ( | const TStr & | Key | ) | const [inline] |
Definition at line 791 of file hash.h.
References TStr::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::GetKeyId().
Referenced by TStrHash< TDat, TStringPool, THashFunc >::GetKeyId().
int TStrHash< TDat, TStringPool, THashFunc >::GetKeyOfs | ( | const int & | KeyId | ) | const [inline] |
Definition at line 793 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat(), and THashKeyDat< TKey, TDat >::Key.
{ return GetHashKeyDat(KeyId).Key; } // pool string id
void TStrHash< TDat, TStringPool, THashFunc >::GetKeyV | ( | TVec< TStr > & | KeyV | ) | const |
Definition at line 910 of file hash.h.
References TVec< TVal >::Add(), and TVec< TVal >::Gen().
{ KeyV.Gen(Len(), 0); int KeyId = FFirstKeyId(); while (FNextKeyId(KeyId)) KeyV.Add(GetKey(KeyId)); }
int TStrHash< TDat, TStringPool, THashFunc >::GetMxKeyIds | ( | ) | const [inline] |
Definition at line 757 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::KeyDatV, and TVec< TVal >::Len().
uint TStrHash< TDat, TStringPool, THashFunc >::GetNextPrime | ( | const uint & | Val | ) | const [private] |
Definition at line 818 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; }
PStringPool TStrHash< TDat, TStringPool, THashFunc >::GetPool | ( | ) | const [inline] |
Definition at line 748 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::Pool.
{ return Pool; }
int TStrHash< TDat, TStringPool, THashFunc >::GetPorts | ( | ) | const [inline] |
Definition at line 755 of file hash.h.
References TVec< TVal >::Len(), and TStrHash< TDat, TStringPool, THashFunc >::PortV.
void TStrHash< TDat, TStringPool, THashFunc >::GetStrIdV | ( | TIntV & | StrIdV | ) | const |
Definition at line 918 of file hash.h.
References TVec< TVal >::Add(), and TVec< TVal >::Gen().
{ StrIdV.Gen(Len(), 0); int KeyId = FFirstKeyId(); while (FNextKeyId(KeyId)) StrIdV.Add(GetKeyOfs(KeyId)); }
bool TStrHash< TDat, TStringPool, THashFunc >::IsAutoSize | ( | ) | const [inline] |
Definition at line 756 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::AutoSizeP.
{ return AutoSizeP; }
bool TStrHash< TDat, TStringPool, THashFunc >::IsKey | ( | const char * | Key | ) | const [inline] |
Definition at line 796 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::GetKeyId().
Referenced by TStrUtil::CountWords().
{ return GetKeyId(Key) != -1; }
bool TStrHash< TDat, TStringPool, THashFunc >::IsKey | ( | const TStr & | Key | ) | const [inline] |
Definition at line 797 of file hash.h.
References TStr::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::GetKeyId().
bool TStrHash< TDat, TStringPool, THashFunc >::IsKey | ( | const TChA & | Key | ) | const [inline] |
Definition at line 798 of file hash.h.
References TChA::CStr(), and TStrHash< TDat, TStringPool, THashFunc >::GetKeyId().
bool TStrHash< TDat, TStringPool, THashFunc >::IsKey | ( | const char * | Key, |
int & | KeyId | ||
) | const [inline] |
Definition at line 799 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::GetKeyId().
{ KeyId = GetKeyId(Key); return KeyId != -1; }
bool TStrHash< TDat, TStringPool, THashFunc >::IsKeyGetDat | ( | const char * | Key, |
TDat & | Dat | ||
) | const [inline] |
Definition at line 800 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; }
bool TStrHash< TDat, TStringPool, THashFunc >::IsKeyGetDat | ( | const TStr & | Key, |
TDat & | Dat | ||
) | const [inline] |
Definition at line 801 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; }
bool TStrHash< TDat, TStringPool, THashFunc >::IsKeyGetDat | ( | const TChA & | Key, |
TDat & | Dat | ||
) | const [inline] |
Definition at line 802 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; }
bool TStrHash< TDat, TStringPool, THashFunc >::IsKeyId | ( | const int & | KeyId | ) | const [inline] |
Definition at line 803 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::KeyDatV, and TVec< TVal >::Len().
bool TStrHash< TDat, TStringPool, THashFunc >::IsKeyIdEqKeyN | ( | ) | const [inline] |
Definition at line 758 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::FreeKeys.
{return ! FreeKeys; }
const char* TStrHash< TDat, TStringPool, THashFunc >::KeyFromOfs | ( | const int & | KeyO | ) | const [inline] |
Definition at line 794 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::Pool.
Referenced by TStrHash< TDat, TStringPool, THashFunc >::GetKeyDat().
{ return Pool->GetCStr(KeyO); }
int TStrHash< TDat, TStringPool, THashFunc >::Len | ( | ) | const [inline] |
Definition at line 753 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::FreeKeys, TStrHash< TDat, TStringPool, THashFunc >::KeyDatV, and TVec< TVal >::Len().
Referenced by TStrHash< TDat, TStringPool, THashFunc >::Empty().
void TStrHash< TDat, TStringPool, THashFunc >::Load | ( | TSIn & | SIn, |
bool | PoolToo = true |
||
) | [inline] |
Definition at line 742 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::AutoSizeP, TStrHash< TDat, TStringPool, THashFunc >::FFreeKeyId, TStrHash< TDat, TStringPool, THashFunc >::FreeKeys, TStrHash< TDat, TStringPool, THashFunc >::KeyDatV, TVec< TVal >::Load(), TBool::Load(), TInt::Load(), TSIn::LoadCs(), TStrHash< TDat, TStringPool, THashFunc >::Pool, and TStrHash< TDat, TStringPool, THashFunc >::PortV.
{ PortV.Load(SIn); KeyDatV.Load(SIn); AutoSizeP.Load(SIn); FFreeKeyId.Load(SIn); FreeKeys.Load(SIn); SIn.LoadCs(); if (PoolToo) Pool = PStringPool(SIn); }
const TDat& TStrHash< TDat, TStringPool, THashFunc >::operator() | ( | const char * | Key | ) | const [inline] |
Definition at line 775 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::GetDat().
{ return GetDat(Key);}
TStrHash< TDat, TStringPool, THashFunc > & TStrHash< TDat, TStringPool, THashFunc >::operator= | ( | const TStrHash< TDat, TStringPool, THashFunc > & | Hash | ) |
Definition at line 853 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::AutoSizeP, TPt< TRec >::Empty(), TStrHash< TDat, TStringPool, THashFunc >::FFreeKeyId, TStrHash< TDat, TStringPool, THashFunc >::FreeKeys, TStrHash< TDat, TStringPool, THashFunc >::KeyDatV, TStrHash< TDat, TStringPool, THashFunc >::Pool, and TStrHash< TDat, TStringPool, THashFunc >::PortV.
{ if (this != &Hash) { PortV = Hash.PortV; KeyDatV = Hash.KeyDatV; AutoSizeP = Hash.AutoSizeP; FFreeKeyId = Hash.FFreeKeyId; FreeKeys = Hash.FreeKeys; if (! Hash.Pool.Empty()) Pool = PStringPool(new TStringPool(*Hash.Pool)); else Pool = NULL; } return *this; }
const TDat& TStrHash< TDat, TStringPool, THashFunc >::operator[] | ( | const int & | KeyId | ) | const [inline] |
Definition at line 773 of file hash.h.
References THashKeyDat< TKey, TDat >::Dat, and TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat().
{return GetHashKeyDat(KeyId).Dat;}
TDat& TStrHash< TDat, TStringPool, THashFunc >::operator[] | ( | const int & | KeyId | ) | [inline] |
Definition at line 774 of file hash.h.
References THashKeyDat< TKey, TDat >::Dat, and TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat().
{return GetHashKeyDat(KeyId).Dat;}
void TStrHash< TDat, TStringPool, THashFunc >::Pack | ( | ) | [inline] |
Definition at line 814 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::KeyDatV, and TVec< TVal >::Pack().
int TStrHash< TDat, TStringPool, THashFunc >::Reserved | ( | ) | const [inline] |
Definition at line 754 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::KeyDatV, and TVec< TVal >::Reserved().
void TStrHash< TDat, TStringPool, THashFunc >::Resize | ( | ) | [private] |
Definition at line 830 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; } } }
void TStrHash< TDat, TStringPool, THashFunc >::Save | ( | TSOut & | SOut, |
bool | PoolToo = true |
||
) | const [inline] |
Definition at line 744 of file hash.h.
References TStrHash< TDat, TStringPool, THashFunc >::AutoSizeP, TStrHash< TDat, TStringPool, THashFunc >::FFreeKeyId, TStrHash< TDat, TStringPool, THashFunc >::FreeKeys, TStrHash< TDat, TStringPool, THashFunc >::KeyDatV, TStrHash< TDat, TStringPool, THashFunc >::Pool, TStrHash< TDat, TStringPool, THashFunc >::PortV, TVec< TVal >::Save(), TPt< TRec >::Save(), TBool::Save(), TInt::Save(), and TSOut::SaveCs().
{ PortV.Save(SOut); KeyDatV.Save(SOut); AutoSizeP.Save(SOut); FFreeKeyId.Save(SOut); FreeKeys.Save(SOut); SOut.SaveCs(); if (PoolToo) Pool.Save(SOut); }
void TStrHash< TDat, TStringPool, THashFunc >::SetPool | ( | const PStringPool & | StrPool | ) | [inline] |
TBool TStrHash< TDat, TStringPool, THashFunc >::AutoSizeP [private] |
Definition at line 722 of file hash.h.
Referenced by TStrHash< TDat, TStringPool, THashFunc >::IsAutoSize(), TStrHash< TDat, TStringPool, THashFunc >::Load(), TStrHash< TDat, TStringPool, THashFunc >::operator=(), and TStrHash< TDat, TStringPool, THashFunc >::Save().
TInt TStrHash< TDat, TStringPool, THashFunc >::FFreeKeyId [private] |
Definition at line 723 of file hash.h.
Referenced by TStrHash< TDat, TStringPool, THashFunc >::Load(), TStrHash< TDat, TStringPool, THashFunc >::operator=(), and TStrHash< TDat, TStringPool, THashFunc >::Save().
TInt TStrHash< TDat, TStringPool, THashFunc >::FreeKeys [private] |
Definition at line 723 of file hash.h.
Referenced by TStrHash< TDat, TStringPool, THashFunc >::IsKeyIdEqKeyN(), TStrHash< TDat, TStringPool, THashFunc >::Len(), TStrHash< TDat, TStringPool, THashFunc >::Load(), TStrHash< TDat, TStringPool, THashFunc >::operator=(), and TStrHash< TDat, TStringPool, THashFunc >::Save().
THKeyDatV TStrHash< TDat, TStringPool, THashFunc >::KeyDatV [private] |
Definition at line 721 of file hash.h.
Referenced by TStrHash< TDat, TStringPool, THashFunc >::AddDat(), TStrHash< TDat, TStringPool, THashFunc >::AddDatId(), TStrHash< TDat, TStringPool, THashFunc >::GetDat(), TStrHash< TDat, TStringPool, THashFunc >::GetDatId(), TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat(), TStrHash< TDat, TStringPool, THashFunc >::GetMxKeyIds(), TStrHash< TDat, TStringPool, THashFunc >::IsKeyGetDat(), TStrHash< TDat, TStringPool, THashFunc >::IsKeyId(), TStrHash< TDat, TStringPool, THashFunc >::Len(), TStrHash< TDat, TStringPool, THashFunc >::Load(), TStrHash< TDat, TStringPool, THashFunc >::operator=(), TStrHash< TDat, TStringPool, THashFunc >::Pack(), TStrHash< TDat, TStringPool, THashFunc >::Reserved(), and TStrHash< TDat, TStringPool, THashFunc >::Save().
PStringPool TStrHash< TDat, TStringPool, THashFunc >::Pool [private] |
Definition at line 724 of file hash.h.
Referenced by TStrHash< TDat, TStringPool, THashFunc >::GetKey(), TStrHash< TDat, TStringPool, THashFunc >::GetPool(), TStrHash< TDat, TStringPool, THashFunc >::KeyFromOfs(), TStrHash< TDat, TStringPool, THashFunc >::Load(), TStrHash< TDat, TStringPool, THashFunc >::operator=(), TStrHash< TDat, TStringPool, THashFunc >::Save(), TStrHash< TDat, TStringPool, THashFunc >::SetPool(), and TStrHash< TDat, TStringPool, THashFunc >::TStrHash().
TIntV TStrHash< TDat, TStringPool, THashFunc >::PortV [private] |
Definition at line 720 of file hash.h.
Referenced by TStrHash< TDat, TStringPool, THashFunc >::GetPorts(), TStrHash< TDat, TStringPool, THashFunc >::Load(), TStrHash< TDat, TStringPool, THashFunc >::operator=(), TStrHash< TDat, TStringPool, THashFunc >::Save(), and TStrHash< TDat, TStringPool, THashFunc >::TStrHash().