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
TStrHash< TDat, TStringPool, THashFunc > Class Template Reference

#include <hash.h>

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

Public Types

typedef TPt< TStringPool > PStringPool
 

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 LoadShM (TShMIn &ShMIn, bool SharedPool=true)
 Load hash from shared memory. If shared pool is true load pool from shared memory. More...
 
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
 
::TSize GetMemUsed () 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 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 781 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

Definition at line 784 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 786 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 788 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 787 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 802 of file hash.h.

802 : PortV(), KeyDatV(), AutoSizeP(true), FFreeKeyId(-1), FreeKeys(0), Pool() { }
PStringPool Pool
Definition: hash.h:793
TInt FreeKeys
Definition: hash.h:792
TInt FFreeKeyId
Definition: hash.h:792
TIntV PortV
Definition: hash.h:789
THKeyDatV KeyDatV
Definition: hash.h:790
TBool AutoSizeP
Definition: hash.h:791
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TStrHash< TDat, TStringPool, THashFunc >::TStrHash ( const PStringPool StrPool)
inline

Definition at line 803 of file hash.h.

803 : PortV(), KeyDatV(), AutoSizeP(true), FFreeKeyId(-1), FreeKeys(0), Pool(StrPool) { }
PStringPool Pool
Definition: hash.h:793
TInt FreeKeys
Definition: hash.h:792
TInt FFreeKeyId
Definition: hash.h:792
TIntV PortV
Definition: hash.h:789
THKeyDatV KeyDatV
Definition: hash.h:790
TBool AutoSizeP
Definition: hash.h:791
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 804 of file hash.h.

804  :
805  PortV(Ports), KeyDatV(Ports, 0), AutoSizeP(_AutoSizeP), FFreeKeyId(-1), FreeKeys(0), Pool(StrPool) { PortV.PutAll(-1); }
PStringPool Pool
Definition: hash.h:793
TInt FreeKeys
Definition: hash.h:792
TInt FFreeKeyId
Definition: hash.h:792
TIntV PortV
Definition: hash.h:789
void PutAll(const TVal &Val)
Sets all elements of the vector to value Val.
Definition: ds.h:1229
THKeyDatV KeyDatV
Definition: hash.h:790
TBool AutoSizeP
Definition: hash.h:791
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 806 of file hash.h.

806  : PortV(Hash.PortV), KeyDatV(Hash.KeyDatV), AutoSizeP(Hash.AutoSizeP),
807  FFreeKeyId(Hash.FFreeKeyId), FreeKeys(Hash.FreeKeys), Pool() {
808  if (! Hash.Pool.Empty()) { Pool=PStringPool(new TStringPool(*Hash.Pool)); } }
PStringPool Pool
Definition: hash.h:793
TInt FreeKeys
Definition: hash.h:792
bool Empty() const
Definition: bd.h:501
TInt FFreeKeyId
Definition: hash.h:792
TIntV PortV
Definition: hash.h:789
THKeyDatV KeyDatV
Definition: hash.h:790
TBool AutoSizeP
Definition: hash.h:791
TPt< TStringPool > PStringPool
Definition: hash.h:784
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TStrHash< TDat, TStringPool, THashFunc >::TStrHash ( TSIn SIn,
bool  PoolToo = true 
)
inline

Definition at line 809 of file hash.h.

809 : PortV(SIn), KeyDatV(SIn), AutoSizeP(SIn), FFreeKeyId(SIn), FreeKeys(SIn){ SIn.LoadCs(); if (PoolToo) Pool = PStringPool(SIn); }
PStringPool Pool
Definition: hash.h:793
TInt FreeKeys
Definition: hash.h:792
TInt FFreeKeyId
Definition: hash.h:792
TIntV PortV
Definition: hash.h:789
virtual void LoadCs()
Definition: fl.cpp:28
THKeyDatV KeyDatV
Definition: hash.h:790
TBool AutoSizeP
Definition: hash.h:791
TPt< TStringPool > PStringPool
Definition: hash.h:784

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 852 of file hash.h.

852 { const int KeyId = AddKey(Key); KeyDatV[KeyId].Dat = Dat; return KeyId; }
THKeyDatV KeyDatV
Definition: hash.h:790
int AddKey(const char *Key)
Definition: hash.h:968
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 853 of file hash.h.

853 { const int KeyId = AddKey(Key.CStr()); KeyDatV[KeyId].Dat = Dat; return KeyId; }
THKeyDatV KeyDatV
Definition: hash.h:790
int AddKey(const char *Key)
Definition: hash.h:968
char * CStr()
Definition: dt.h:476
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 854 of file hash.h.

854 { const int KeyId = AddKey(Key.CStr()); KeyDatV[KeyId].Dat = Dat; return KeyId; }
char * CStr()
Definition: dt.h:255
THKeyDatV KeyDatV
Definition: hash.h:790
int AddKey(const char *Key)
Definition: hash.h:968
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDat ( const char *  Key)
inline

Definition at line 855 of file hash.h.

855 { return KeyDatV[AddKey(Key)].Dat; }
THKeyDatV KeyDatV
Definition: hash.h:790
int AddKey(const char *Key)
Definition: hash.h:968
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDat ( const TStr Key)
inline

Definition at line 856 of file hash.h.

856 { return KeyDatV[AddKey(Key.CStr())].Dat; }
THKeyDatV KeyDatV
Definition: hash.h:790
int AddKey(const char *Key)
Definition: hash.h:968
char * CStr()
Definition: dt.h:476
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDat ( const TChA Key)
inline

Definition at line 857 of file hash.h.

857 { return KeyDatV[AddKey(Key.CStr())].Dat; }
char * CStr()
Definition: dt.h:255
THKeyDatV KeyDatV
Definition: hash.h:790
int AddKey(const char *Key)
Definition: hash.h:968
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDatId ( const char *  Key)
inline

Definition at line 858 of file hash.h.

Referenced by TSnap::LoadConnListStr().

858 { const int KeyId = AddKey(Key); return KeyDatV[KeyId].Dat = KeyId; }
THKeyDatV KeyDatV
Definition: hash.h:790
int AddKey(const char *Key)
Definition: hash.h:968

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 859 of file hash.h.

859 { const int KeyId = AddKey(Key.CStr()); return KeyDatV[KeyId].Dat = KeyId; }
THKeyDatV KeyDatV
Definition: hash.h:790
int AddKey(const char *Key)
Definition: hash.h:968
char * CStr()
Definition: dt.h:476
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TDat& TStrHash< TDat, TStringPool, THashFunc >::AddDatId ( const TChA Key)
inline

Definition at line 860 of file hash.h.

860 { const int KeyId = AddKey(Key.CStr()); return KeyDatV[KeyId].Dat = KeyId; }
char * CStr()
Definition: dt.h:255
THKeyDatV KeyDatV
Definition: hash.h:790
int AddKey(const char *Key)
Definition: hash.h:968
template<class TDat , class TStringPool , class THashFunc >
int TStrHash< TDat, TStringPool, THashFunc >::AddKey ( const char *  Key)

Definition at line 968 of file hash.h.

Referenced by TStrHash< TInt, TBigStrPool >::AddDat(), TStrHash< TInt, TBigStrPool >::AddDatId(), TTableContext::AddStr(), TTable::AddStrVal(), TTable::ChangeContext(), TTable::ColConcat(), TTable::ColConcatConst(), TCoda::DumpMemberships(), TSnap::LoadEdgeListStr(), TAGMUtil::LoadEdgeListStr(), TTimeNENet::LoadEdgeTm(), and TTable::StoreStrCol().

968  {
969  if (Pool.Empty()) Pool = TStringPool::New();
970  if ((AutoSizeP && KeyDatV.Len() > PortV.Len()) || PortV.Empty()) Resize();
971  const int PortN = abs(THashFunc::GetPrimHashCd(Key) % PortV.Len());
972  const int HashCd = abs(THashFunc::GetSecHashCd(Key));
973  int PrevKeyId = -1;
974  int KeyId = PortV[PortN];
975  while (KeyId != -1 && ! (KeyDatV[KeyId].HashCd == HashCd && Pool->Cmp(KeyDatV[KeyId].Key, Key) == 0)) {
976  PrevKeyId = KeyId; KeyId = KeyDatV[KeyId].Next; }
977  if (KeyId == -1) {
978  const int StrId = Pool->AddStr(Key);
979  if (FFreeKeyId == -1) {
980  KeyId = KeyDatV.Add(THKeyDat(-1, HashCd, StrId));
981  } else {
982  KeyId = FFreeKeyId;
983  FFreeKeyId = KeyDatV[FFreeKeyId].Next;
984  FreeKeys--;
985  KeyDatV[KeyId] = THKeyDat(-1, HashCd, StrId);
986  }
987  if (PrevKeyId == -1) PortV[PortN] = KeyId;
988  else KeyDatV[PrevKeyId].Next = KeyId;
989  }
990  return KeyId;
991 }
PStringPool Pool
Definition: hash.h:793
TInt FreeKeys
Definition: hash.h:792
bool Empty() const
Definition: bd.h:501
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TInt FFreeKeyId
Definition: hash.h:792
TIntV PortV
Definition: hash.h:789
bool Empty() const
Tests whether the vector is empty.
Definition: ds.h:570
THKeyDatV KeyDatV
Definition: hash.h:790
void Resize()
Definition: hash.h:931
TBool AutoSizeP
Definition: hash.h:791
THashKeyDat< TInt, TDat > THKeyDat
Definition: hash.h:786
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602

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 850 of file hash.h.

Referenced by TStrHash< TInt, TBigStrPool >::AddKey().

850 { return AddKey(Key.CStr()); }
int AddKey(const char *Key)
Definition: hash.h:968
char * CStr()
Definition: dt.h:476

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 851 of file hash.h.

Referenced by TStrHash< TInt, TBigStrPool >::AddKey().

851 { return AddKey(Key.CStr()); }
char * CStr()
Definition: dt.h:255
int AddKey(const char *Key)
Definition: hash.h:968

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 841 of file hash.h.

841 {return ! Len(); }
int Len() const
Definition: hash.h:842
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
int TStrHash< TDat, TStringPool, THashFunc >::FFirstKeyId ( ) const
inline

Definition at line 906 of file hash.h.

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

Definition at line 1005 of file hash.h.

1005  {
1006  do KeyId++; while (KeyId < KeyDatV.Len() && KeyDatV[KeyId].HashCd == -1);
1007  return KeyId < KeyDatV.Len();
1008 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
THKeyDatV KeyDatV
Definition: hash.h:790
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 879 of file hash.h.

Referenced by TStrHash< TInt, TBigStrPool >::operator()().

879 { return KeyDatV[GetKeyId(Key)].Dat; }
THKeyDatV KeyDatV
Definition: hash.h:790
int GetKeyId(const char *Key) const
Definition: hash.h:994

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 880 of file hash.h.

Referenced by TStrHash< TInt, TBigStrPool >::GetDat().

880 { return GetDat(Key.CStr()); }
char * CStr()
Definition: dt.h:476
const TDat & GetDat(const char *Key) const
Definition: hash.h:879

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 881 of file hash.h.

881 { return KeyDatV[GetKeyId(Key)].Dat; }
THKeyDatV KeyDatV
Definition: hash.h:790
int GetKeyId(const char *Key) const
Definition: hash.h:994
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
const TDat& TStrHash< TDat, TStringPool, THashFunc >::GetDat ( const TStr Key)
inline

Definition at line 882 of file hash.h.

Referenced by TStrHash< TInt, TBigStrPool >::GetDat().

882 { return GetDat(Key.CStr()); }
char * CStr()
Definition: dt.h:476
const TDat & GetDat(const char *Key) const
Definition: hash.h:879

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 883 of file hash.h.

Referenced by TStrHash< TInt, TBigStrPool >::GetDat().

883 { return GetDat(Key.CStr()); }
char * CStr()
Definition: dt.h:255
const TDat & GetDat(const char *Key) const
Definition: hash.h:879

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 884 of file hash.h.

884 { return KeyDatV[KeyId].Dat; }
THKeyDatV KeyDatV
Definition: hash.h:790
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 885 of file hash.h.

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

Definition at line 1046 of file hash.h.

1046  {
1047  DatKeyPrV.Gen(Len(), 0);
1048  TStr Str; TDat Dat;
1049  int KeyId = FFirstKeyId();
1050  while (FNextKeyId(KeyId)){
1051  GetKeyDat(KeyId, Str, Dat);
1052  DatKeyPrV.Add(TPair<TDat, TStr>(Dat, Str));
1053  }
1054 }
int FFirstKeyId() const
Definition: hash.h:906
int Len() const
Definition: hash.h:842
bool FNextKeyId(int &KeyId) const
Definition: hash.h:1005
void GetKeyDat(const int &KeyId, int &KeyO, TDat &Dat) const
Definition: hash.h:886
Definition: ds.h:32
Definition: dt.h:412
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
template<class TDat, class TStringPool , class THashFunc >
void TStrHash< TDat, TStringPool, THashFunc >::GetDatV ( TVec< TDat > &  DatV) const

Definition at line 1027 of file hash.h.

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

1027  {
1028  DatV.Gen(Len(), 0);
1029  int KeyId = FFirstKeyId();
1030  while (FNextKeyId(KeyId))
1031  DatV.Add(GetHashKeyDat(KeyId).Dat);
1032 }
int FFirstKeyId() const
Definition: hash.h:906
int Len() const
Definition: hash.h:842
bool FNextKeyId(int &KeyId) const
Definition: hash.h:1005
const THKeyDat & GetHashKeyDat(const int &KeyId) const
Definition: hash.h:797
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523
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 TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
const THKeyDat& TStrHash< TDat, TStringPool, THashFunc >::GetHashKeyDat ( const int &  KeyId) const
inlineprivate

Definition at line 797 of file hash.h.

Referenced by TStrHash< TInt, TBigStrPool >::GetKey(), TStrHash< TInt, TBigStrPool >::GetKeyDat(), TStrHash< TInt, TBigStrPool >::GetKeyOfs(), and TStrHash< TInt, TBigStrPool >::operator[]().

797  {
798  const THKeyDat& KeyDat = KeyDatV[KeyId]; Assert(KeyDat.HashCd != -1); return KeyDat; }
#define Assert(Cond)
Definition: bd.h:251
THKeyDatV KeyDatV
Definition: hash.h:790
THashKeyDat< TInt, TDat > THKeyDat
Definition: hash.h:786

Here is the caller graph for this function:

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

Definition at line 799 of file hash.h.

799  {
800  THKeyDat& KeyDat = KeyDatV[KeyId]; Assert(KeyDat.HashCd != -1); return KeyDat; }
#define Assert(Cond)
Definition: bd.h:251
THKeyDatV KeyDatV
Definition: hash.h:790
THashKeyDat< TInt, TDat > THKeyDat
Definition: hash.h:786
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 893 of file hash.h.

Referenced by TTable::BuildGraph(), TCesna::DisplayAttrs(), TCoda::DumpMemberships(), TCesnaUtil::DumpNIDAttrHToNIDK(), TTable::GetContextKey(), TTableContext::GetStr(), TTable::GetStr(), TTable::GetStrVal(), and TAGMUtil::LoadEdgeListStr().

893 { return Pool->GetCStr(GetHashKeyDat(KeyId).Key); }
PStringPool Pool
Definition: hash.h:793
const THKeyDat & GetHashKeyDat(const int &KeyId) const
Definition: hash.h:797

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 886 of file hash.h.

886 { const THKeyDat& KeyDat = GetHashKeyDat(KeyId); KeyO = KeyDat.Key; Dat = KeyDat.Dat; }
const THKeyDat & GetHashKeyDat(const int &KeyId) const
Definition: hash.h:797
THashKeyDat< TInt, TDat > THKeyDat
Definition: hash.h:786
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 887 of file hash.h.

887 { const THKeyDat& KeyDat = GetHashKeyDat(KeyId); Key = KeyFromOfs(KeyDat.Key); Dat = KeyDat.Dat; }
const char * KeyFromOfs(const int &KeyO) const
Definition: hash.h:895
const THKeyDat & GetHashKeyDat(const int &KeyId) const
Definition: hash.h:797
THashKeyDat< TInt, TDat > THKeyDat
Definition: hash.h:786
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 888 of file hash.h.

888 { const THKeyDat& KeyDat = GetHashKeyDat(KeyId); Key = KeyFromOfs(KeyDat.Key); Dat = KeyDat.Dat;}
const char * KeyFromOfs(const int &KeyO) const
Definition: hash.h:895
const THKeyDat & GetHashKeyDat(const int &KeyId) const
Definition: hash.h:797
THashKeyDat< TInt, TDat > THKeyDat
Definition: hash.h:786
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 889 of file hash.h.

889 { const THKeyDat& KeyDat = GetHashKeyDat(KeyId); Key = KeyFromOfs(KeyDat.Key); Dat = KeyDat.Dat;}
const char * KeyFromOfs(const int &KeyO) const
Definition: hash.h:895
const THKeyDat & GetHashKeyDat(const int &KeyId) const
Definition: hash.h:797
THashKeyDat< TInt, TDat > THKeyDat
Definition: hash.h:786
template<class TDat, class TStringPool , class THashFunc >
void TStrHash< TDat, TStringPool, THashFunc >::GetKeyDatPrV ( TVec< TPair< TStr, TDat > > &  KeyDatPrV) const

Definition at line 1035 of file hash.h.

1035  {
1036  KeyDatPrV.Gen(Len(), 0);
1037  TStr Str; TDat Dat;
1038  int KeyId = FFirstKeyId();
1039  while (FNextKeyId(KeyId)){
1040  GetKeyDat(KeyId, Str, Dat);
1041  KeyDatPrV.Add(TPair<TStr, TDat>(Str, Dat));
1042  }
1043 }
int FFirstKeyId() const
Definition: hash.h:906
int Len() const
Definition: hash.h:842
bool FNextKeyId(int &KeyId) const
Definition: hash.h:1005
void GetKeyDat(const int &KeyId, int &KeyO, TDat &Dat) const
Definition: hash.h:886
Definition: ds.h:32
Definition: dt.h:412
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
template<class TDat , class TStringPool , class THashFunc >
int TStrHash< TDat, TStringPool, THashFunc >::GetKeyId ( const char *  Key) const

Definition at line 994 of file hash.h.

Referenced by TStrHash< TInt, TBigStrPool >::GetDat(), TStrHash< TInt, TBigStrPool >::IsKey(), TStrHash< TInt, TBigStrPool >::IsKeyGetDat(), TAGMUtil::LoadCmtyVV(), TCesnaUtil::LoadNIDAttrHFromNIDKH(), and TTable::StoreStrCol().

994  {
995  if (PortV.Empty()) return -1;
996  const int PortN = abs(THashFunc::GetPrimHashCd(Key) % PortV.Len());
997  const int Hc = abs(THashFunc::GetSecHashCd(Key));
998  int KeyId = PortV[PortN];
999  while (KeyId != -1 && ! (KeyDatV[KeyId].HashCd == Hc && Pool->Cmp(KeyDatV[KeyId].Key, Key) == 0))
1000  KeyId = KeyDatV[KeyId].Next;
1001  return KeyId;
1002 }
PStringPool Pool
Definition: hash.h:793
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TIntV PortV
Definition: hash.h:789
bool Empty() const
Tests whether the vector is empty.
Definition: ds.h:570
THKeyDatV KeyDatV
Definition: hash.h:790

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 892 of file hash.h.

Referenced by TStrHash< TInt, TBigStrPool >::GetKeyId().

892 { return GetKeyId(Key.CStr()); }
char * CStr()
Definition: dt.h:476
int GetKeyId(const char *Key) const
Definition: hash.h:994

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 894 of file hash.h.

894 { return GetHashKeyDat(KeyId).Key; } // pool string id
const THKeyDat & GetHashKeyDat(const int &KeyId) const
Definition: hash.h:797
TKey Key
Definition: hash.h:12
template<class TDat , class TStringPool , class THashFunc >
void TStrHash< TDat, TStringPool, THashFunc >::GetKeyV ( TVec< TStr > &  KeyV) const

Definition at line 1011 of file hash.h.

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

1011  {
1012  KeyV.Gen(Len(), 0);
1013  int KeyId = FFirstKeyId();
1014  while (FNextKeyId(KeyId))
1015  KeyV.Add(GetKey(KeyId));
1016 }
int FFirstKeyId() const
Definition: hash.h:906
int Len() const
Definition: hash.h:842
bool FNextKeyId(int &KeyId) const
Definition: hash.h:1005
const char * GetKey(const int &KeyId) const
Definition: hash.h:893
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523
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 TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
::TSize TStrHash< TDat, TStringPool, THashFunc >::GetMemUsed ( ) const
inline

Definition at line 866 of file hash.h.

Referenced by TTable::GetContextMemUsedKB().

866  {
867  int64 MemUsed = sizeof(bool)+2*sizeof(int);
868  MemUsed += int64(PortV.Reserved()) * int64(sizeof(TInt));
869  for (int KeyDatN = 0; KeyDatN < KeyDatV.Len(); KeyDatN++) {
870  MemUsed += int64(2 * sizeof(TInt));
871  MemUsed += int64(KeyDatV[KeyDatN].Key.GetMemUsed());
872  MemUsed += int64(KeyDatV[KeyDatN].Dat.GetMemUsed());
873  }
874  // printf("TStrHash: Memory used for hash table: %s\n", TUInt64::GetStr(MemUsed).CStr());
875  MemUsed += 8 + Pool->GetMemUsed();
876  return ::TSize(MemUsed/1000);
877  }
TSizeTy Reserved() const
Returns the size of allocated storage capacity.
Definition: ds.h:577
PStringPool Pool
Definition: hash.h:793
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TIntV PortV
Definition: hash.h:789
TSizeTy GetMemUsed() const
Returns the memory footprint (the number of bytes) of the vector.
Definition: ds.h:511
size_t TSize
Definition: bd.h:58
THKeyDatV KeyDatV
Definition: hash.h:790
Definition: dt.h:1134
long long int64
Definition: bd.h:27

Here is the caller 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 846 of file hash.h.

846 { return KeyDatV.Len(); }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
THKeyDatV KeyDatV
Definition: hash.h:790
template<class TDat , class TStringPool , class THashFunc >
uint TStrHash< TDat, TStringPool, THashFunc >::GetNextPrime ( const uint Val) const
private

Definition at line 919 of file hash.h.

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

919  {
920  uint *f = (uint *) TIntH::HashPrimeT, *m, *l = (uint *) TIntH::HashPrimeT + (int) TIntH::HashPrimes;
921  int h, len = (int)TIntH::HashPrimes;
922  while (len > 0) {
923  h = len >> 1; m = f + h;
924  if (*m < Val) { f = m; f++; len = len - h - 1; }
925  else len = h;
926  }
927  return f == l ? *(l - 1) : *f;
928 }
unsigned int uint
Definition: bd.h:11
static const unsigned int HashPrimeT[HashPrimes]
Definition: hash.h:100
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
PStringPool TStrHash< TDat, TStringPool, THashFunc >::GetPool ( ) const
inline

Definition at line 837 of file hash.h.

837 { return Pool; }
PStringPool Pool
Definition: hash.h:793
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
int TStrHash< TDat, TStringPool, THashFunc >::GetPorts ( ) const
inline

Definition at line 844 of file hash.h.

844 { return PortV.Len(); }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TIntV PortV
Definition: hash.h:789
template<class TDat , class TStringPool , class THashFunc >
void TStrHash< TDat, TStringPool, THashFunc >::GetStrIdV ( TIntV StrIdV) const

Definition at line 1019 of file hash.h.

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

1019  {
1020  StrIdV.Gen(Len(), 0);
1021  int KeyId = FFirstKeyId();
1022  while (FNextKeyId(KeyId))
1023  StrIdV.Add(GetKeyOfs(KeyId));
1024 }
int GetKeyOfs(const int &KeyId) const
Definition: hash.h:894
int FFirstKeyId() const
Definition: hash.h:906
int Len() const
Definition: hash.h:842
bool FNextKeyId(int &KeyId) const
Definition: hash.h:1005
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523
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 TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
bool TStrHash< TDat, TStringPool, THashFunc >::IsAutoSize ( ) const
inline

Definition at line 845 of file hash.h.

845 { return AutoSizeP; }
TBool AutoSizeP
Definition: hash.h:791
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
bool TStrHash< TDat, TStringPool, THashFunc >::IsKey ( const char *  Key) const
inline

Definition at line 897 of file hash.h.

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

897 { return GetKeyId(Key) != -1; }
int GetKeyId(const char *Key) const
Definition: hash.h:994

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 898 of file hash.h.

898 { return GetKeyId(Key.CStr()) != -1; }
char * CStr()
Definition: dt.h:476
int GetKeyId(const char *Key) const
Definition: hash.h:994
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
bool TStrHash< TDat, TStringPool, THashFunc >::IsKey ( const TChA Key) const
inline

Definition at line 899 of file hash.h.

899 { return GetKeyId(Key.CStr()) != -1; }
char * CStr()
Definition: dt.h:255
int GetKeyId(const char *Key) const
Definition: hash.h:994
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 900 of file hash.h.

900 { KeyId = GetKeyId(Key); return KeyId != -1; }
int GetKeyId(const char *Key) const
Definition: hash.h:994
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 901 of file hash.h.

901 { const int KeyId = GetKeyId(Key); if (KeyId != -1) { Dat = KeyDatV[KeyId].Dat; return true; } else return false; }
THKeyDatV KeyDatV
Definition: hash.h:790
int GetKeyId(const char *Key) const
Definition: hash.h:994
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 902 of file hash.h.

902 { const int KeyId = GetKeyId(Key.CStr()); if (KeyId != -1) { Dat = KeyDatV[KeyId].Dat; return true; } else return false; }
THKeyDatV KeyDatV
Definition: hash.h:790
char * CStr()
Definition: dt.h:476
int GetKeyId(const char *Key) const
Definition: hash.h:994
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 903 of file hash.h.

903 { const int KeyId = GetKeyId(Key.CStr()); if (KeyId != -1) { Dat = KeyDatV[KeyId].Dat; return true; } else return false; }
char * CStr()
Definition: dt.h:255
THKeyDatV KeyDatV
Definition: hash.h:790
int GetKeyId(const char *Key) const
Definition: hash.h:994
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
bool TStrHash< TDat, TStringPool, THashFunc >::IsKeyId ( const int &  KeyId) const
inline

Definition at line 904 of file hash.h.

Referenced by TCesnaUtil::DumpNIDAttrHToNIDK().

904 { return 0 <= KeyId && KeyId < KeyDatV.Len() && KeyDatV[KeyId].HashCd != -1; }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
THKeyDatV KeyDatV
Definition: hash.h:790

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 847 of file hash.h.

847 {return ! FreeKeys; }
TInt FreeKeys
Definition: hash.h:792
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 895 of file hash.h.

Referenced by TStrHash< TInt, TBigStrPool >::GetKeyDat().

895 { return Pool->GetCStr(KeyO); }
PStringPool Pool
Definition: hash.h:793

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

Definition at line 842 of file hash.h.

Referenced by TCesna::DisplayAttrs(), TCoda::DumpMemberships(), TStrHash< TInt, TBigStrPool >::Empty(), TAGMUtil::LoadEdgeListStr(), TCesnaUtil::LoadNIDAttrHFromNIDKH(), and TTable::PrintContextSize().

842 { return KeyDatV.Len() - FreeKeys; }
TInt FreeKeys
Definition: hash.h:792
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
THKeyDatV KeyDatV
Definition: hash.h:790

Here is the caller graph for this function:

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

Definition at line 811 of file hash.h.

Referenced by TTableContext::Load().

811  {PortV.Load(SIn); KeyDatV.Load(SIn); AutoSizeP.Load(SIn); FFreeKeyId.Load(SIn);
812  FreeKeys.Load(SIn); SIn.LoadCs(); if (PoolToo) Pool = PStringPool(SIn);}
PStringPool Pool
Definition: hash.h:793
TInt FreeKeys
Definition: hash.h:792
void Load(TSIn &SIn)
Definition: dt.h:991
TInt FFreeKeyId
Definition: hash.h:792
TIntV PortV
Definition: hash.h:789
void Load(TSIn &SIn)
Definition: ds.h:946
virtual void LoadCs()
Definition: fl.cpp:28
void Load(TSIn &SIn)
Definition: dt.h:1149
THKeyDatV KeyDatV
Definition: hash.h:790
TBool AutoSizeP
Definition: hash.h:791
TPt< TStringPool > PStringPool
Definition: hash.h:784

Here is the caller graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
void TStrHash< TDat, TStringPool, THashFunc >::LoadShM ( TShMIn ShMIn,
bool  SharedPool = true 
)
inline

Load hash from shared memory. If shared pool is true load pool from shared memory.

Definition at line 815 of file hash.h.

Referenced by TTableContext::LoadShM().

815  {
816  PortV.LoadShM(ShMIn);
817  KeyDatV.Load(ShMIn);
818  AutoSizeP.Load(ShMIn);
819  FFreeKeyId.Load(ShMIn);
820  FreeKeys.Load(ShMIn);
821  ShMIn.LoadCs();
822  if (SharedPool) {
823  TBool isNull;
824  isNull.Load(ShMIn);
825  if (!isNull) {
826  Pool = TStringPool::LoadShM(ShMIn);
827  }
828  } else {
829  Pool = PStringPool(ShMIn);
830  }
831  }
PStringPool Pool
Definition: hash.h:793
TInt FreeKeys
Definition: hash.h:792
void Load(TSIn &SIn)
Definition: dt.h:991
TInt FFreeKeyId
Definition: hash.h:792
TIntV PortV
Definition: hash.h:789
void Load(TSIn &SIn)
Definition: ds.h:946
void Load(TSIn &SIn)
Definition: dt.h:1149
THKeyDatV KeyDatV
Definition: hash.h:790
void LoadShM(TShMIn &ShMIn)
Constructs the vector from a shared memory input.
Definition: ds.h:932
TBool AutoSizeP
Definition: hash.h:791
TPt< TStringPool > PStringPool
Definition: hash.h:784
Definition: dt.h:971
void LoadCs()
Definition: fl.h:408

Here is the caller graph for this function:

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 864 of file hash.h.

864 { return GetDat(Key);}
const TDat & GetDat(const char *Key) const
Definition: hash.h:879
template<class TDat , class TStringPool , class THashFunc >
TStrHash< TDat, TStringPool, THashFunc > & TStrHash< TDat, TStringPool, THashFunc >::operator= ( const TStrHash< TDat, TStringPool, THashFunc > &  Hash)

Definition at line 954 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.

954  {
955  if (this != &Hash) {
956  PortV = Hash.PortV;
957  KeyDatV = Hash.KeyDatV;
958  AutoSizeP = Hash.AutoSizeP;
959  FFreeKeyId = Hash.FFreeKeyId;
960  FreeKeys = Hash.FreeKeys;
961  if (! Hash.Pool.Empty()) Pool = PStringPool(new TStringPool(*Hash.Pool));
962  else Pool = NULL;
963  }
964  return *this;
965 }
PStringPool Pool
Definition: hash.h:793
TInt FreeKeys
Definition: hash.h:792
bool Empty() const
Definition: bd.h:501
TInt FFreeKeyId
Definition: hash.h:792
TIntV PortV
Definition: hash.h:789
THKeyDatV KeyDatV
Definition: hash.h:790
TBool AutoSizeP
Definition: hash.h:791
TPt< TStringPool > PStringPool
Definition: hash.h:784

Here is the call graph for this function:

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 862 of file hash.h.

862 {return GetHashKeyDat(KeyId).Dat;}
TDat Dat
Definition: hash.h:13
const THKeyDat & GetHashKeyDat(const int &KeyId) const
Definition: hash.h:797
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
TDat& TStrHash< TDat, TStringPool, THashFunc >::operator[] ( const int &  KeyId)
inline

Definition at line 863 of file hash.h.

863 {return GetHashKeyDat(KeyId).Dat;}
TDat Dat
Definition: hash.h:13
const THKeyDat & GetHashKeyDat(const int &KeyId) const
Definition: hash.h:797
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
void TStrHash< TDat, TStringPool, THashFunc >::Pack ( )
inline

Definition at line 915 of file hash.h.

Referenced by TAGMUtil::LoadEdgeListStr().

915 {KeyDatV.Pack();}
THKeyDatV KeyDatV
Definition: hash.h:790
void Pack()
Reduces vector capacity (frees memory) to match its size.
Definition: ds.h:1057

Here is the caller 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 843 of file hash.h.

Referenced by TTable::PrintContextSize().

843 { return KeyDatV.Reserved(); }
TSizeTy Reserved() const
Returns the size of allocated storage capacity.
Definition: ds.h:577
THKeyDatV KeyDatV
Definition: hash.h:790

Here is the caller graph for this function:

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

Definition at line 931 of file hash.h.

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

931  {
932  // resize & initialize port vector
933  if (PortV.Empty()) { PortV.Gen(17); PortV.PutAll(-1); }
934  else
935  if (AutoSizeP && KeyDatV.Len() > 3 * PortV.Len()) {
936  const int NxPrime = GetNextPrime(KeyDatV.Len());
937  //printf("%s resize PortV: %d -> %d, Len: %d\n", GetTypeNm(*this).CStr(), PortV.Len(), NxPrime, Len());
938  PortV.Gen(NxPrime); PortV.PutAll(-1); }
939  else
940  return;
941  // rehash keys
942  const int NPorts = PortV.Len();
943  for (int i = 0; i < KeyDatV.Len(); i++) {
944  THKeyDat& KeyDat = KeyDatV[i];
945  if (KeyDat.HashCd != -1) {
946  const int Port = abs(THashFunc::GetPrimHashCd(Pool->GetCStr(KeyDat.Key)) % NPorts);
947  KeyDat.Next = PortV[Port];
948  PortV[Port] = i;
949  }
950  }
951 }
PStringPool Pool
Definition: hash.h:793
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TIntV PortV
Definition: hash.h:789
bool Empty() const
Tests whether the vector is empty.
Definition: ds.h:570
void PutAll(const TVal &Val)
Sets all elements of the vector to value Val.
Definition: ds.h:1229
THKeyDatV KeyDatV
Definition: hash.h:790
uint GetNextPrime(const uint &Val) const
Definition: hash.h:919
TBool AutoSizeP
Definition: hash.h:791
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523
THashKeyDat< TInt, TDat > THKeyDat
Definition: hash.h:786
template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
void TStrHash< TDat, TStringPool, THashFunc >::Save ( TSOut SOut,
bool  PoolToo = true 
) const
inline

Definition at line 833 of file hash.h.

Referenced by TTableContext::Save().

833  { PortV.Save(SOut); KeyDatV.Save(SOut);
834  AutoSizeP.Save(SOut); FFreeKeyId.Save(SOut); FreeKeys.Save(SOut); SOut.SaveCs(); if (PoolToo) Pool.Save(SOut); }
PStringPool Pool
Definition: hash.h:793
TInt FreeKeys
Definition: hash.h:792
void Save(TSOut &SOut) const
Definition: dt.h:1150
TInt FFreeKeyId
Definition: hash.h:792
void Save(TSOut &SOut) const
Definition: dt.h:992
TIntV PortV
Definition: hash.h:789
void Save(TSOut &SOut) const
Definition: ds.h:954
void SaveCs()
Definition: fl.h:171
THKeyDatV KeyDatV
Definition: hash.h:790
TBool AutoSizeP
Definition: hash.h:791
void Save(TSOut &SOut) const
Definition: xmlser.h:16

Here is the caller graph for this function:

template<class TDat, class TStringPool = TStrPool, class THashFunc = TDefaultHashFunc<TStr>>
void TStrHash< TDat, TStringPool, THashFunc >::SetPool ( const PStringPool StrPool)
inline

Definition at line 836 of file hash.h.

836 { IAssert(Pool.Empty() || Pool->Empty()); Pool = StrPool; }
#define IAssert(Cond)
Definition: bd.h:262
PStringPool Pool
Definition: hash.h:793
bool Empty() const
Definition: bd.h:501

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

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