SNAP Library, Developer Reference  2012-10-15 15:06:59
SNAP, a general purpose network analysis and graph mining library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
THash< TKey, TDat, THashFunc > Class Template Reference

#include <hash.h>

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

List of all members.

Classes

class  THashKeyDatCmp

Public Types

enum  { HashPrimes = 32 }
typedef THashKeyDatI< TKey, TDat > TIter

Public Member Functions

 THash ()
 THash (const THash &Hash)
 THash (const int &ExpectVals, const bool &_AutoSizeP=false)
 THash (TSIn &SIn)
void Load (TSIn &SIn)
void Save (TSOut &SOut) const
void LoadXml (const PXmlTok &XmlTok, const TStr &Nm="")
void SaveXml (TSOut &SOut, const TStr &Nm)
THashoperator= (const THash &Hash)
bool operator== (const THash &Hash) const
bool operator< (const THash &Hash) const
const TDat & operator[] (const int &KeyId) const
TDat & operator[] (const int &KeyId)
TDat & operator() (const TKey &Key)
::TSize GetMemUsed () const
TIter BegI () const
TIter EndI () const
TIter GetI (const TKey &Key) const
void Gen (const int &ExpectVals)
void Clr (const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
bool Empty () const
int Len () const
int GetPorts () const
bool IsAutoSize () const
int GetMxKeyIds () const
int GetReservedKeyIds () const
bool IsKeyIdEqKeyN () const
int AddKey (const TKey &Key)
TDat & AddDatId (const TKey &Key)
TDat & AddDat (const TKey &Key)
TDat & AddDat (const TKey &Key, const TDat &Dat)
void DelKey (const TKey &Key)
void DelIfKey (const TKey &Key)
void DelKeyId (const int &KeyId)
void DelKeyIdV (const TIntV &KeyIdV)
void MarkDelKey (const TKey &Key)
void MarkDelKeyId (const int &KeyId)
const TKey & GetKey (const int &KeyId) const
int GetKeyId (const TKey &Key) const
int GetRndKeyId (TRnd &Rnd) const
 Get an index of a random element. If the hash table has many deleted keys, this may take a long time.
int GetRndKeyId (TRnd &Rnd, const double &EmptyFrac)
 Get an index of a random element. If the hash table has many deleted keys, defrag the hash table first (that's why the function is non-const).
bool IsKey (const TKey &Key) const
bool IsKey (const TKey &Key, int &KeyId) const
bool IsKeyId (const int &KeyId) const
const TDat & GetDat (const TKey &Key) const
TDat & GetDat (const TKey &Key)
void GetKeyDat (const int &KeyId, TKey &Key, TDat &Dat) const
bool IsKeyGetDat (const TKey &Key, TDat &Dat) const
int FFirstKeyId () const
bool FNextKeyId (int &KeyId) const
void GetKeyV (TVec< TKey > &KeyV) const
void GetDatV (TVec< TDat > &DatV) const
void GetKeyDatPrV (TVec< TPair< TKey, TDat > > &KeyDatPrV) const
void GetDatKeyPrV (TVec< TPair< TDat, TKey > > &DatKeyPrV) const
void GetKeyDatKdV (TVec< TKeyDat< TKey, TDat > > &KeyDatKdV) const
void GetDatKeyKdV (TVec< TKeyDat< TDat, TKey > > &DatKeyKdV) const
void Swap (THash &Hash)
void Defrag ()
void Pack ()
void Sort (const bool &CmpKey, const bool &Asc)
void SortByKey (const bool &Asc=true)
void SortByDat (const bool &Asc=true)

Static Public Attributes

static const unsigned int HashPrimeT [HashPrimes]

Private Types

typedef THashKeyDat< TKey, TDat > THKeyDat
typedef TPair< TKey, TDat > TKeyDatP

Private Member Functions

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

Private Attributes

TIntV PortV
TVec< THKeyDatKeyDatV
TBool AutoSizeP
TInt FFreeKeyId
TInt FreeKeys

Detailed Description

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

Definition at line 85 of file hash.h.


Member Typedef Documentation

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
typedef THashKeyDat<TKey, TDat> THash< TKey, TDat, THashFunc >::THKeyDat [private]

Definition at line 92 of file hash.h.

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
typedef THashKeyDatI<TKey, TDat> THash< TKey, TDat, THashFunc >::TIter

Definition at line 90 of file hash.h.

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
typedef TPair<TKey, TDat> THash< TKey, TDat, THashFunc >::TKeyDatP [private]

Definition at line 93 of file hash.h.


Member Enumeration Documentation

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
anonymous enum
Enumerator:
HashPrimes 

Definition at line 87 of file hash.h.

{HashPrimes=32};

Constructor & Destructor Documentation

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
THash< TKey, TDat, THashFunc >::THash ( ) [inline]

Definition at line 123 of file hash.h.

         :
    PortV(), KeyDatV(),
    AutoSizeP(true), FFreeKeyId(-1), FreeKeys(0){}
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
THash< TKey, TDat, THashFunc >::THash ( const THash< TKey, TDat, THashFunc > &  Hash) [inline]

Definition at line 126 of file hash.h.

template<class TKey , class TDat , class THashFunc >
THash< TKey, TDat, THashFunc >::THash ( const int &  ExpectVals,
const bool &  _AutoSizeP = false 
) [explicit]

Definition at line 293 of file hash.h.

References THash< TKey, TDat, THashFunc >::PortV, and TVec< TVal >::PutAll().

                                                                                :
  PortV(GetNextPrime(ExpectVals/2)), KeyDatV(ExpectVals, 0),
  AutoSizeP(_AutoSizeP), FFreeKeyId(-1), FreeKeys(0){
  PortV.PutAll(TInt(-1));
}

Here is the call graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
THash< TKey, TDat, THashFunc >::THash ( TSIn SIn) [inline, explicit]

Definition at line 130 of file hash.h.

                           :
    PortV(SIn), KeyDatV(SIn),
    AutoSizeP(SIn), FFreeKeyId(SIn), FreeKeys(SIn){
    SIn.LoadCs();}

Member Function Documentation

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
TDat& THash< TKey, TDat, THashFunc >::AddDat ( const TKey &  Key) [inline]

Definition at line 192 of file hash.h.

Referenced by TUnionFind::Add(), TUniTrie< TInt >::Add(), TExpBi::AddBi(), TLocClustStat::AddCut(), TNEGraph::AddEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::AddEdge(), AddFldVal(), AddHdFld(), TUNGraph::AddNode(), TNGraph::AddNode(), TNEGraph::AddNode(), TNodeEdgeNet< TNodeData, TEdgeData >::AddNode(), TSnap::TSnapDetail::TCNMQMatrix::TCmtyDat::AddQ(), TILx::AddRw(), TOLx::AddRw(), TLocClustStat::AddToBestCutH(), TLocClust::ApproxPageRank(), TGStat::AvgGStat(), TLocClustStat::BagOfWhiskers(), TLocClustStat::BagOfWhiskers2(), TForestFire::BurnExpFire(), TForestFire::BurnGeoFire(), TSnap::TSnapDetail::TCNMQMatrix::CmtyCMN(), TSnap::CommunityGirvanNewman(), TArtPointVisitor::DiscoverNode(), TBiConVisitor::DiscoverNode(), TSccVisitor< PGraph, OnlyCount >::DiscoverNode(), TLocClust::DrawWhiskers(), TSpecFunc::EntropyBias(), TZipIn::FillFExtToCmdH(), TZipOut::FillFExtToCmdH(), TSccVisitor< PGraph, OnlyCount >::FinishNode(), TSnap::GetBetweennessCentr(), TSnap::GetBfsEffDiam(), TSnap::GetBiConSzCnt(), TSnap::GetClustCf(), TSnap::GetDegCnt(), TCnCom::GetDfsVisitor(), TSnap::GetEigenVectorCentr(), TSnap::GetHits(), TSnap::GetInDegCnt(), TSnap::GetNodeClustCf(), TAGM::GetNodeMembership(), TSnap::GetNodesAtHops(), TGraphEnumUtils::GetNormalizedMap(), TSnap::GetOutDegCnt(), TSnap::GetPageRank(), TLxSymStr::GetSSym(), TBigNet< TNodeData, IsDir >::GetSubGraph(), TXmlObjSer::GetTagNm(), TSnap::GetTriadParticip(), TGStat::GetValStr(), TSnap::TSnapDetail::TCNMQMatrix::Init(), TUniChDb::InitScripts(), TUniChDb::InitSpecialCasing(), TUniChDb::InitWordAndSentenceBoundaryFlags(), TBigNet< TNodeData, IsDir >::InvertFromSources(), TTimeNet::LoadArxiv(), TKeyDatFl< TKey, TDat, THashFunc >::LoadHash(), TUniCaseFolding::LoadTxt(), TUniChDb::LoadTxt(), TDGraphCounter::operator()(), THash< TInt, TEdge >::operator()(), ParseHttpResp(), ParseHttpRq(), TNcpGraphsBase::PlotAvgNcp(), TLocClustStat::PlotBoltzmanCurve(), TSnap::PlotEigValDistr(), TLocClustStat::PlotPhiDistr(), TSnap::PlotShortPathDistr(), TSnap::PlotSngValDistr(), TXmlLx::PutEntityVal(), TXmlLx::PutPEntityVal(), PutVarVal(), TUnicode::RegisterCodec(), TBigNet< TNodeData, IsDir >::Rewire(), TLocClustStat::Run(), TBigNet< TNodeData, IsDir >::SaveToDisk(), TGStat::SetDistr(), SetEntityVal(), SetEscStr(), TGStat::SetVal(), TGStat::TakeClustCf(), TGStat::TakeConnComp(), TGStat::TakeDegDistr(), TGStat::TakeDiam(), TGStat::TakeSpectral(), TGStat::TakeTriadPart(), TD34GraphCounter::TD34GraphCounter(), THttpRq(), TMacro(), TPreproc::TPreproc(), TArtPointVisitor::TreeEdge(), and TBiConVisitor::TreeEdge().

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

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
TDat& THash< TKey, TDat, THashFunc >::AddDat ( const TKey &  Key,
const TDat &  Dat 
) [inline]

Definition at line 193 of file hash.h.

                                                {
    return KeyDatV[AddKey(Key)].Dat=Dat;}
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
TDat& THash< TKey, TDat, THashFunc >::AddDatId ( const TKey &  Key) [inline]

Definition at line 190 of file hash.h.

                                 {
    int KeyId=AddKey(Key); return KeyDatV[KeyId].Dat=KeyId;}
template<class TKey, class TDat , class THashFunc >
int THash< TKey, TDat, THashFunc >::AddKey ( const TKey &  Key)

Definition at line 323 of file hash.h.

References GetPrimHashCd(), GetSecHashCd(), PortN, and Resize().

Referenced by TUniTrie< TInt >::Add(), THash< TInt, TEdge >::AddDat(), THash< TInt, TEdge >::AddDatId(), AddKeyVal(), AddToKeyVal(), TLocClustStat::BagOfWhiskers(), TTimeNENet::GetEdgeTmBuckets(), TSnap::GetSngVals(), TSnap::GetSngVec(), TStrCache::GetStr(), TTimeNet::GetTmBuckets(), TTimeNENet::GetTmBuckets(), TUniChDb::InitDerivedCoreProperties(), TUniChDb::InitLineBreaks(), TUniChDb::InitPropList(), TUniChDb::InitScripts(), IsBreakTag(), TUniChDb::LoadTxt(), TSnap::PrintInfo(), TUniChDb::TSubcatHelper::ProcessComment(), TSubGraphsEnum::RecurBfs1(), TGraphKey::TakeGraph(), TGraphKey::TakeSig(), and TUniChDb::TestComposition().

                                                       {
  if ((KeyDatV.Len()>2*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) && (KeyDatV[KeyId].Key==Key))){
    PrevKeyId=KeyId; KeyId=KeyDatV[KeyId].Next;}

  if (KeyId==-1){
    if (FFreeKeyId==-1){
      KeyId=KeyDatV.Add(THKeyDat(-1, HashCd, Key));
    } else {
      KeyId=FFreeKeyId; FFreeKeyId=KeyDatV[FFreeKeyId].Next; FreeKeys--;
      //KeyDatV[KeyId]=TKeyDat(-1, HashCd, Key); // slow version
      KeyDatV[KeyId].Next=-1;
      KeyDatV[KeyId].HashCd=HashCd;
      KeyDatV[KeyId].Key=Key;
      //KeyDatV[KeyId].Dat=TDat(); // already empty
    }
    if (PrevKeyId==-1){
      PortV[PortN]=KeyId;
    } else {
      KeyDatV[PrevKeyId].Next=KeyId;
    }
  }
  return KeyId;
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
TIter THash< TKey, TDat, THashFunc >::BegI ( ) const [inline]
template<class TKey , class TDat , class THashFunc >
void THash< TKey, TDat, THashFunc >::Clr ( const bool &  DoDel = true,
const int &  NoDelLim = -1,
const bool &  ResetDat = true 
)
template<class TKey , class TDat , class THashFunc >
void THash< TKey, TDat, THashFunc >::Defrag ( )

Definition at line 505 of file hash.h.

References IAssert, and operator=().

Referenced by TUNGraph::Defrag(), TGHash< TUInt64 >::Defrag(), TNGraph::Defrag(), TNEGraph::Defrag(), TNodeEdgeNet< TNodeData, TEdgeData >::Defrag(), and TBigNet< TNodeData, IsDir >::Rewire().

                                         {
  if (!IsKeyIdEqKeyN()){
    THash<TKey, TDat, THashFunc> Hash(PortV.Len());
    int KeyId=FFirstKeyId(); TKey Key; TDat Dat;
    while (FNextKeyId(KeyId)){
      GetKeyDat(KeyId, Key, Dat);
      Hash.AddDat(Key, Dat);
    }
    Pack();
    operator=(Hash);
    IAssert(IsKeyIdEqKeyN());
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
void THash< TKey, TDat, THashFunc >::DelIfKey ( const TKey &  Key) [inline]

Definition at line 197 of file hash.h.

                                {
    int KeyId; if (IsKey(Key, KeyId)){DelKeyId(KeyId);}}
template<class TKey, class TDat , class THashFunc >
void THash< TKey, TDat, THashFunc >::DelKey ( const TKey &  Key)

Definition at line 354 of file hash.h.

References GetPrimHashCd(), GetSecHashCd(), IAssert, and PortN.

Referenced by TNEGraph::DelEdge(), TNodeEdgeNet< TNodeData, TEdgeData >::DelEdge(), THash< TInt, TEdge >::DelKeyId(), TSnap::TSnapDetail::TCNMQMatrix::TCmtyDat::DelLink(), TUNGraph::DelNode(), TNGraph::DelNode(), TNEGraph::DelNode(), TBPGraph::DelNode(), TNodeEdgeNet< TNodeData, TEdgeData >::DelNode(), TSnap::TSnapDetail::TCNMQMatrix::MergeBestQ(), TSubGraphsEnum::RecurBfs1(), TBigNet< TNodeData, IsDir >::Rewire(), TUnicode::UnregisterCodec(), and TUniChDb::TSubcatHelper::~TSubcatHelper().

                                                        {
  IAssert(!PortV.Empty());
  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) && (KeyDatV[KeyId].Key==Key))){
    PrevKeyId=KeyId; KeyId=KeyDatV[KeyId].Next;}

  //IAssertR(KeyId!=-1, Key.GetStr()); //J: vsi razredi nimajo nujno funkcije GetStr()?
  IAssert(KeyId!=-1); //J: vsi razredi nimajo nujno funkcije GetStr()?
  if (PrevKeyId==-1){PortV[PortN]=KeyDatV[KeyId].Next;}
  else {KeyDatV[PrevKeyId].Next=KeyDatV[KeyId].Next;}
  KeyDatV[KeyId].Next=FFreeKeyId; FFreeKeyId=KeyId; FreeKeys++;
  KeyDatV[KeyId].HashCd=TInt(-1);
  KeyDatV[KeyId].Key=TKey();
  KeyDatV[KeyId].Dat=TDat();
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
void THash< TKey, TDat, THashFunc >::DelKeyId ( const int &  KeyId) [inline]

Definition at line 199 of file hash.h.

Referenced by THash< TInt, TEdge >::DelIfKey(), and THash< TInt, TEdge >::DelKeyIdV().

{DelKey(GetKey(KeyId));}

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
void THash< TKey, TDat, THashFunc >::DelKeyIdV ( const TIntV KeyIdV) [inline]

Definition at line 200 of file hash.h.

                                     {
    for (int KeyIdN=0; KeyIdN<KeyIdV.Len(); KeyIdN++){DelKeyId(KeyIdV[KeyIdN]);}}
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
void THash< TKey, TDat, THashFunc >::Gen ( const int &  ExpectVals) [inline]
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
const TDat& THash< TKey, TDat, THashFunc >::GetDat ( const TKey &  Key) const [inline]

Definition at line 216 of file hash.h.

Referenced by TSnap::TSnapDetail::_GirvanNewmanGetModularity(), AddKeyVal(), TLocClustStat::AddToBestCutH(), AddToKeyVal(), TLocClust::ApproxPageRank(), TArtPointVisitor::BackEdge(), TBiConVisitor::BackEdge(), TLocClustStat::BagOfWhiskers(), TLocClustStat::BagOfWhiskers2(), TBPGraph::DelNode(), TSpecFunc::EntropyBias(), TLocClustStat::FindBestCut(), TSnap::TSnapDetail::TCNMQMatrix::FindMxQEdge(), TArtPointVisitor::FinishNode(), TBiConVisitor::FinishNode(), TSccVisitor< PGraph, OnlyCount >::FinishNode(), TArtPointVisitor::FwdEdge(), TSnap::GetBetweennessCentr(), TSnap::GetBfsTree(), TZipIn::GetCmd(), TZipOut::GetCmd(), TD34GraphCounter::GetCnt(), TGHash< TUInt64 >::GetDat(), TCnCom::GetDfsVisitor(), TGStat::GetDistr(), TNodeEdgeNet< TSecTm, TSecTm >::GetEDat(), TNEGraph::GetEdge(), TNodeEdgeNet< TSecTm, TSecTm >::GetEdge(), TTimeNENet::GetEdgeTmBuckets(), TSnap::GetEigenVectorCentr(), TExpBi::GetExpBiArgType(), GetFldValV(), GetFullUrlStr(), TSnap::GetHits(), TLocClustStat::GetKNodeCut(), TSccVisitor< PGraph, OnlyCount >::GetMinDiscTm(), TBigNet< TNodeData, IsDir >::GetNDat(), TNodeNet< TSecTm >::GetNDat(), TNodeEDatNet< TNodeData, TEdgeData >::GetNDat(), TNodeEdgeNet< TSecTm, TSecTm >::GetNDat(), TGraphAnf< PGraph >::GetNIdOffset(), TBigNet< TNodeData, IsDir >::GetNode(), TNodeNet< TSecTm >::GetNode(), TUNGraph::GetNode(), TNGraph::GetNode(), TNodeEDatNet< TNodeData, TEdgeData >::GetNode(), TNEGraph::GetNode(), TNodeEdgeNet< TSecTm, TSecTm >::GetNode(), TGraphEnumUtils::GetNormalizedGraph(), TSnap::GetPageRank(), TILx::GetRw(), TTimeNet::GetTmBuckets(), TTimeNENet::GetTmBuckets(), TGStat::GetVal(), GetVal(), GetVals(), TGStat::GetValStr(), GetVarVal(), TAGM::GVizComGraph(), TUniChDb::InitWordAndSentenceBoundaryFlags(), TBigNet< TNodeData, IsDir >::InvertFromSources(), TPreproc::IsSubstId(), TTimeNet::LoadArxiv(), TUniChDb::LoadTxt(), TSnap::TSnapDetail::TCNMQMatrix::MergeBestQ(), TD34GraphCounter::operator()(), TDGraphCounter::operator()(), TGHash< TUInt64 >::operator()(), TGStat::operator<(), THash< TKey, TDat, THashFunc >::operator==(), TUnionFind::Parent(), TLocClustStat::PlotPhiDistr(), TUnionFind::Rank(), TBigNet< TNodeData, IsDir >::Rewire(), TLocClustStat::Run(), TSnap::SaveGViz(), TSnap::SavePajek(), and TNodeEdgeNet< TNodeData, TEdgeData >::SetNDat().

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

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
TDat& THash< TKey, TDat, THashFunc >::GetDat ( const TKey &  Key) [inline]

Definition at line 217 of file hash.h.

{return KeyDatV[GetKeyId(Key)].Dat;}
template<class TKey, class TDat, class THashFunc >
void THash< TKey, TDat, THashFunc >::GetDatKeyKdV ( TVec< TKeyDat< TDat, TKey > > &  DatKeyKdV) const

Definition at line 483 of file hash.h.

References Len().

                                                                                           {
  DatKeyKdV.Gen(Len(), 0);
  TKey Key; TDat Dat;
  int KeyId=FFirstKeyId();
  while (FNextKeyId(KeyId)){
    GetKeyDat(KeyId, Key, Dat);
    DatKeyKdV.Add(TKeyDat<TDat, TKey>(Dat, Key));
  }
}

Here is the call graph for this function:

template<class TKey, class TDat, class THashFunc >
void THash< TKey, TDat, THashFunc >::GetDatKeyPrV ( TVec< TPair< TDat, TKey > > &  DatKeyPrV) const

Definition at line 461 of file hash.h.

References Len().

Referenced by TGHash< TUInt64 >::GetDatKeyPrV().

                                                                                         {
  DatKeyPrV.Gen(Len(), 0);
  TKey Key; TDat Dat;
  int KeyId=FFirstKeyId();
  while (FNextKeyId(KeyId)){
    GetKeyDat(KeyId, Key, Dat);
    DatKeyPrV.Add(TPair<TDat, TKey>(Dat, Key));
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TKey , class TDat, class THashFunc >
void THash< TKey, TDat, THashFunc >::GetDatV ( TVec< TDat > &  DatV) const

Definition at line 442 of file hash.h.

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

Referenced by TGHash< TUInt64 >::GetDatV().

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

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
THKeyDat& THash< TKey, TDat, THashFunc >::GetHashKeyDat ( const int &  KeyId) [inline, private]

Definition at line 114 of file hash.h.

Referenced by THash< TInt, TEdge >::GetKey(), THash< TInt, TEdge >::GetKeyDat(), THash< TInt, TEdge >::IsKeyGetDat(), and THash< TInt, TEdge >::operator[]().

                                           {
    THKeyDat& KeyDat=KeyDatV[KeyId];
    Assert(KeyDat.HashCd!=-1); return KeyDat;}

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
const THKeyDat& THash< TKey, TDat, THashFunc >::GetHashKeyDat ( const int &  KeyId) const [inline, private]

Definition at line 117 of file hash.h.

                                                        {
    const THKeyDat& KeyDat=KeyDatV[KeyId];
    Assert(KeyDat.HashCd!=-1); return KeyDat;}
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
TIter THash< TKey, TDat, THashFunc >::GetI ( const TKey &  Key) const [inline]
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
const TKey& THash< TKey, TDat, THashFunc >::GetKey ( const int &  KeyId) const [inline]

Definition at line 206 of file hash.h.

Referenced by TGnuPlot::AddPlot(), TLocClustStat::BagOfWhiskers(), TLocClustStat::BagOfWhiskers2(), TForestFire::BurnExpFire(), TForestFire::BurnGeoFire(), TSnap::TSnapDetail::CmtyGirvanNewmanStep(), THash< TInt, TEdge >::DelKeyId(), TUnionFind::Dump(), TLocClust::FindBestCut(), TSnap::GetBfsEffDiam(), TSnap::GetBfsTree(), TLocClustStat::GetBoltzmanCurveStat(), TSnap::GetClustCf(), TLocClustStat::GetCurveStat(), TSnap::GetDegCnt(), GetDstSubstStr(), TNEGraph::GetEIdV(), TNodeEdgeNet< TNodeData, TEdgeData >::GetEIdV(), TSnap::GetEigenVectorCentr(), GetFldNmVal(), TD34GraphCounter::GetId(), TSnap::GetInDegCnt(), TGHash< TUInt64 >::GetKey(), TUnionFind::GetKeyI(), TSnap::TSnapDetail::TCNMQMatrix::TCmtyDat::GetMxQNId(), TUNGraph::GetNIdV(), TNGraph::GetNIdV(), TNEGraph::GetNIdV(), TNodeEdgeNet< TNodeData, TEdgeData >::GetNIdV(), TAGM::GetNodeMembership(), TNetConstraint< PGraph >::GetNodePr(), TSnap::GetNodesAtHop(), TSnap::GetOutDegCnt(), TNEGraph::GetRndEId(), TNodeEdgeNet< TSecTm, TSecTm >::GetRndEId(), TBigNet< TNodeData, IsDir >::GetRndNId(), TNodeNet< TSecTm >::GetRndNId(), TUNGraph::GetRndNId(), TNGraph::GetRndNId(), TNodeEDatNet< TNodeData, TEdgeData >::GetRndNId(), TNEGraph::GetRndNId(), TNodeEdgeNet< TSecTm, TSecTm >::GetRndNId(), TUniChDb::GetScriptName(), GetSrcSubstStr(), TStrCache::GetStr(), GetVarNm(), TUniChDb::InitScripts(), TUniChDb::InitWordAndSentenceBoundaryFlags(), TTimeNet::LoadArxiv(), TUniChDb::LoadTxt(), THash< TInt, TEdge >::MarkDelKeyId(), TSnap::TSnapDetail::TCNMQMatrix::MergeBestQ(), TLocClustStat::PlotBestClustDens(), TLocClustStat::PlotBoltzmanCurve(), TLocClustStat::PlotNCPModul(), TLocClustStat::PlotNCPScatter(), TSnap::PlotShortPathDistr(), TGnuPlot::PlotValCntH(), TGnuPlot::PlotValMomH(), TBigNet< TNodeData, IsDir >::Rewire(), TKeyDatFl< TKey, TDat, THashFunc >::Save(), TLocClust::SupportSweep(), TUniChDb::TestComposition(), TUniChDb::TestWbFindNonIgnored(), and TUniChDb::TSubcatHelper::~TSubcatHelper().

{ return GetHashKeyDat(KeyId).Key;}

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
void THash< TKey, TDat, THashFunc >::GetKeyDat ( const int &  KeyId,
TKey &  Key,
TDat &  Dat 
) const [inline]

Definition at line 221 of file hash.h.

Referenced by TGHash< TUInt64 >::GetKeyDat().

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

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc >
void THash< TKey, TDat, THashFunc >::GetKeyDatKdV ( TVec< TKeyDat< TKey, TDat > > &  KeyDatKdV) const

Definition at line 472 of file hash.h.

References Len().

                                                                                           {
  KeyDatKdV.Gen(Len(), 0);
  TKey Key; TDat Dat;
  int KeyId=FFirstKeyId();
  while (FNextKeyId(KeyId)){
    GetKeyDat(KeyId, Key, Dat);
    KeyDatKdV.Add(TKeyDat<TKey, TDat>(Key, Dat));
  }
}

Here is the call graph for this function:

template<class TKey, class TDat, class THashFunc >
void THash< TKey, TDat, THashFunc >::GetKeyDatPrV ( TVec< TPair< TKey, TDat > > &  KeyDatPrV) const

Definition at line 450 of file hash.h.

References Len().

Referenced by TGStat::AvgGStat(), TSnap::GetBiConSzCnt(), TTimeNENet::GetEdgeTmBuckets(), TGHash< TUInt64 >::GetKeyDatPrV(), TSnap::GetNodesAtHops(), TSnap::GetSccSzCnt(), TTimeNet::GetTmBuckets(), TTimeNENet::GetTmBuckets(), TSnap::GetTriadParticip(), TSnap::PlotEigValDistr(), and TSnap::PlotSngValDistr().

                                                                                         {
  KeyDatPrV.Gen(Len(), 0);
  TKey Key; TDat Dat;
  int KeyId=FFirstKeyId();
  while (FNextKeyId(KeyId)){
    GetKeyDat(KeyId, Key, Dat);
    KeyDatPrV.Add(TPair<TKey, TDat>(Key, Dat));
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TKey, class TDat , class THashFunc >
int THash< TKey, TDat, THashFunc >::GetKeyId ( const TKey &  Key) const

Definition at line 416 of file hash.h.

References GetPrimHashCd(), GetSecHashCd(), and PortN.

Referenced by TUniTrie< TInt >::Add(), TUniChDb::AddDecomposition(), TSnap::TSnapDetail::TCNMQMatrix::TCmtyDat::AddQ(), TUniChDb::Compose(), TUniCaseFolding::Fold(), TUniCaseFolding::FoldInPlace(), TUniTrie< TInt >::Get3GramRoot(), TUniChDb::GetCaseConverted(), TUniChDb::GetCat(), TUniChDb::GetCharName(), TUniChDb::GetCombiningClass(), THash< TInt, TEdge >::GetDat(), GetEscStr(), THash< TInt, TEdge >::GetI(), TGHash< TUInt64 >::GetKeyId(), TUniChDb::GetSbFlags(), TUniChDb::GetScript(), TUniChDb::GetScriptByName(), TUniChDb::GetSimpleCaseConverted(), TSnap::GetSngVals(), TSnap::GetSngVec(), GetSrcSubstStrN(), TLxSymStr::GetSSym(), TUniChDb::GetSubCat(), TILx::GetSym(), TUniChDb::GetWbFlags(), TUniChDb::InitDerivedCoreProperties(), TUniChDb::InitLineBreaks(), TUniChDb::InitPropList(), TUniChDb::InitScripts(), TUniChDb::InitWordAndSentenceBoundaryFlags(), TUniChDb::IsGetChInfo(), THash< TInt, TEdge >::IsKey(), TUniChDb::IsPrivateUse(), TUniChDb::IsSbFlag(), TUniChDb::IsSurrogate(), TUniChDb::IsWbFlag(), TUniChDb::IsWbIgnored(), TUniChDb::LoadTxt(), TUniChDb::TSubcatHelper::SetCat(), TLocClust::SupportSweep(), TGraphKey::TakeGraph(), TGraphKey::TakeSig(), TUniChDb::TSubcatHelper::TestCat(), and TUniChDb::ToSimpleCaseConverted().

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

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TKey, class TDat , class THashFunc >
void THash< TKey, TDat, THashFunc >::GetKeyV ( TVec< TKey > &  KeyV) const

Definition at line 434 of file hash.h.

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

Referenced by TGHash< TUInt64 >::GetKeyV(), TBreathFS< PGraph >::GetVisitedNIdV(), TSubGraphsEnum::RecurBfs1(), and TBigNet< TNodeData, IsDir >::Rewire().

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

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
::TSize THash< TKey, TDat, THashFunc >::GetMemUsed ( ) const [inline]

Definition at line 155 of file hash.h.

                           {
    // return PortV.GetMemUsed()+KeyDatV.GetMemUsed()+sizeof(bool)+2*sizeof(int);}
      int64 MemUsed = sizeof(bool)+2*sizeof(int);
      MemUsed += int64(PortV.Reserved()) * int64(sizeof(TInt));
      for (int KeyDatN = 0; KeyDatN < KeyDatV.Len(); KeyDatN++) {
          MemUsed += int64(2 * sizeof(TInt));
          MemUsed += int64(KeyDatV[KeyDatN].Key.GetMemUsed());
          MemUsed += int64(KeyDatV[KeyDatN].Dat.GetMemUsed());
      }
      return ::TSize(MemUsed);
  }
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
int THash< TKey, TDat, THashFunc >::GetMxKeyIds ( ) const [inline]

Definition at line 185 of file hash.h.

Referenced by TGHash< TUInt64 >::GetMxKeyIds(), and TBigNet< TNodeData, IsDir >::Rewire().

{return KeyDatV.Len();}

Here is the caller graph for this function:

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

Definition at line 257 of file hash.h.

Referenced by THash< TInt, TEdge >::Gen().

                                                                     {
  const uint* f=(const uint*)HashPrimeT, *m, *l=(const uint*)HashPrimeT + (int)HashPrimes;
  int h, len = (int)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;
}

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
int THash< TKey, TDat, THashFunc >::GetPorts ( ) const [inline]

Definition at line 183 of file hash.h.

Referenced by TGHash< TUInt64 >::GetPorts().

{return PortV.Len();}

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
int THash< TKey, TDat, THashFunc >::GetReservedKeyIds ( ) const [inline]

Definition at line 186 of file hash.h.

{return KeyDatV.Reserved();}
template<class TKey , class TDat , class THashFunc >
int THash< TKey, TDat, THashFunc >::GetRndKeyId ( TRnd Rnd) const

Get an index of a random element. If the hash table has many deleted keys, this may take a long time.

Definition at line 394 of file hash.h.

References Empty(), TRnd::GetUniDevInt(), and IAssert.

Referenced by TNEGraph::GetRndEId(), TNodeEdgeNet< TSecTm, TSecTm >::GetRndEId(), TBigNet< TNodeData, IsDir >::GetRndNId(), TNodeNet< TSecTm >::GetRndNId(), TUNGraph::GetRndNId(), TNGraph::GetRndNId(), TNodeEDatNet< TNodeData, TEdgeData >::GetRndNId(), TNEGraph::GetRndNId(), TNodeEdgeNet< TSecTm, TSecTm >::GetRndNId(), and TBigNet< TNodeData, IsDir >::Rewire().

                                                              {
  IAssert(! Empty());
  int KeyId = abs(Rnd.GetUniDevInt(KeyDatV.Len()));
  while (KeyDatV[KeyId].HashCd == -1) { // if the index is empty, just try again
    KeyId = abs(Rnd.GetUniDevInt(KeyDatV.Len())); }
  return KeyId; 
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TKey , class TDat , class THashFunc >
int THash< TKey, TDat, THashFunc >::GetRndKeyId ( TRnd Rnd,
const double &  EmptyFrac 
)

Get an index of a random element. If the hash table has many deleted keys, defrag the hash table first (that's why the function is non-const).

Definition at line 405 of file hash.h.

References Empty(), TRnd::GetUniDevInt(), IAssert, and Len().

                                                                                {
  IAssert(! Empty());
  if (FreeKeys/double(Len()+FreeKeys) > EmptyFrac) { Defrag(); }
  int KeyId = Rnd.GetUniDevInt(KeyDatV.Len());
  while (KeyDatV[KeyId].HashCd == -1) { // if the index is empty, just try again
    KeyId = Rnd.GetUniDevInt(KeyDatV.Len());
  }
  return KeyId;
}

Here is the call graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
bool THash< TKey, TDat, THashFunc >::IsAutoSize ( ) const [inline]

Definition at line 184 of file hash.h.

Referenced by TGHash< TUInt64 >::IsAutoSize().

{return AutoSizeP;}

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
bool THash< TKey, TDat, THashFunc >::IsKey ( const TKey &  Key) const [inline]

Definition at line 212 of file hash.h.

Referenced by TILx::AddRw(), TOLx::AddRw(), TLocClustStat::AddToBestCutH(), TArtPointVisitor::BackEdge(), TBiConVisitor::BackEdge(), TLocClustStat::BagOfWhiskers(), TLocClustStat::BagOfWhiskers2(), TForestFire::BurnExpFire(), TForestFire::BurnGeoFire(), THash< TInt, TEdge >::DelIfKey(), TSpecFunc::EntropyBias(), TLocClustStat::FindBestCut(), TSnap::TSnapDetail::TCNMQMatrix::FindMxQEdge(), TArtPointVisitor::FinishNode(), TBiConVisitor::FinishNode(), TZipIn::GetCmd(), TZipOut::GetCmd(), TCnCom::GetDfsVisitor(), TGStat::GetDistr(), GetDstTxtStr(), TTimeNENet::GetEdgeTmBuckets(), GetFldValV(), TStrCache::GetStr(), TTimeNet::GetTmBuckets(), TTimeNENet::GetTmBuckets(), TGStat::GetVal(), GetVal(), TGStat::GetValStr(), TUniTrie< TInt >::Has1Gram(), TUniTrie< TInt >::Has2Gram(), TGStat::HasDistr(), TGStat::HasVal(), TUniChDb::InitWordAndSentenceBoundaryFlags(), IsBreakTag(), TNEGraph::IsEdge(), TNodeEdgeNet< TSecTm, TSecTm >::IsEdge(), TExpBi::IsExpBiId(), IsFldNm(), TUnionFind::IsKey(), TGHash< TUInt64 >::IsKey(), THash< TInt, TEdge >::IsKeyGetDat(), TBPGraph::IsLNode(), TBigNet< TNodeData, IsDir >::IsNode(), TNodeNet< TSecTm >::IsNode(), TUNGraph::IsNode(), TNGraph::IsNode(), TNodeEDatNet< TNodeData, TEdgeData >::IsNode(), TNEGraph::IsNode(), TNodeEdgeNet< TSecTm, TSecTm >::IsNode(), TBPGraph::IsRNode(), IsSrcSubstStr(), TPreproc::IsSubstId(), TZipIn::IsZipExt(), TZipOut::IsZipExt(), TTimeNet::LoadArxiv(), TUniCaseFolding::LoadTxt(), TUniChDb::LoadTxt(), TSnap::TSnapDetail::TCNMQMatrix::MergeBestQ(), TD34GraphCounter::operator()(), TDGraphCounter::operator()(), TGStat::operator<(), THash< TKey, TDat, THashFunc >::operator==(), TSubGraphsEnum::RecurBfs1(), TBigNet< TNodeData, IsDir >::Rewire(), TLocClustStat::Run(), TSnap::SaveGViz(), TSnap::SavePajek(), TLocClustStat::SaveTxtInfo(), TUniChDb::TestComposition(), and TUniChDb::TSubcatHelper::~TSubcatHelper().

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

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
bool THash< TKey, TDat, THashFunc >::IsKey ( const TKey &  Key,
int &  KeyId 
) const [inline]

Definition at line 213 of file hash.h.

{ KeyId=GetKeyId(Key); return KeyId!=-1;}
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
bool THash< TKey, TDat, THashFunc >::IsKeyGetDat ( const TKey &  Key,
TDat &  Dat 
) const [inline]

Definition at line 224 of file hash.h.

Referenced by TSnap::GetBfsEffDiam(), TUnicode::GetCodec(), IsEntityNm(), TXmlLx::IsEntityNm(), TGHash< TUInt64 >::IsKeyGetDat(), TBigNet< TNodeData, IsDir >::IsNode(), and TXmlLx::IsPEntityNm().

                                                     {int KeyId;
    if (IsKey(Key, KeyId)){Dat=GetHashKeyDat(KeyId).Dat; return true;}
    else {return false;}}

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
bool THash< TKey, TDat, THashFunc >::IsKeyId ( const int &  KeyId) const [inline]

Definition at line 214 of file hash.h.

Referenced by TGHash< TUInt64 >::IsKeyId().

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

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
bool THash< TKey, TDat, THashFunc >::IsKeyIdEqKeyN ( ) const [inline]

Definition at line 187 of file hash.h.

Referenced by THash< TInt, TEdge >::BegI(), TUNGraph::Defrag(), TNGraph::Defrag(), TNEGraph::Defrag(), TNodeEdgeNet< TNodeData, TEdgeData >::Defrag(), and TGHash< TUInt64 >::IsKeyIdEqKeyN().

{return FreeKeys==0;}

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
int THash< TKey, TDat, THashFunc >::Len ( ) const [inline]

Definition at line 182 of file hash.h.

Referenced by TGnuPlot::AddPlot(), TILx::AddRw(), TOLx::AddRw(), TLocClust::ApproxPageRank(), TLocClustStat::BagOfWhiskers(), TLocClustStat::BagOfWhiskers2(), THash< TInt, TEdge >::BegI(), TForestFire::BurnExpFire(), TForestFire::BurnGeoFire(), TSnap::TSnapDetail::TCNMQMatrix::CmtyCMN(), TUnionFind::Dump(), THash< TInt, TEdge >::Empty(), TLocClust::FindBestCut(), TLocClustStat::FindBestCut(), TSnap::GetBfsEffDiam(), TSnap::GetBfsTree(), TLocClustStat::GetBoltzmanCurveStat(), TSnap::GetClustCf(), TLocClustStat::GetCurveStat(), TLocClustStat::GetCuts(), TSnap::GetDegCnt(), TGStat::GetDistrs(), TNEGraph::GetEdges(), TNodeEdgeNet< TSecTm, TSecTm >::GetEdges(), TSnap::GetEigenVectorCentr(), GetFlds(), GetFldVals(), TSnap::GetHits(), TSnap::GetInDegCnt(), TBPGraph::GetLNodes(), TSnap::GetNodeEcc(), TAGM::GetNodeMembership(), TBigNet< TNodeData, IsDir >::GetNodes(), TNodeNet< TSecTm >::GetNodes(), TUNGraph::GetNodes(), TNGraph::GetNodes(), TNodeEDatNet< TNodeData, TEdgeData >::GetNodes(), TNEGraph::GetNodes(), TNodeEdgeNet< TSecTm, TSecTm >::GetNodes(), TSnap::GetNodesAtHop(), TSnap::GetNodesAtHops(), TBreathFS< PGraph >::GetNVisited(), TSnap::GetOutDegCnt(), TSnap::GetPageRank(), TBPGraph::GetRNodes(), TSnap::GetShortPath(), TLxSymStr::GetSSym(), GetSubstStrs(), TSnap::GetSubTreeSz(), TGStat::GetVals(), GetVars(), TUniChDb::InitScripts(), IsBreakTag(), TD34GraphCounter::Len(), TGHash< TUInt64 >::Len(), TUnionFind::Len(), TNetConstraint< PGraph >::Len(), TTimeNet::LoadArxiv(), TUniCaseFolding::LoadTxt(), TUniChDb::LoadTxt(), THash< TKey, TDat, THashFunc >::operator==(), TLocClustStat::PlotBestClustDens(), TLocClustStat::PlotBoltzmanCurve(), TLocClustStat::PlotNCPModul(), TLocClustStat::PlotNCPScatter(), TLocClustStat::PlotPhiInOut(), TSnap::PlotShortPathDistr(), TGnuPlot::PlotValCntH(), TSnap::PrintInfo(), TBigNet< TNodeData, IsDir >::Rewire(), TLocClustStat::Run(), TKeyDatFl< TKey, TDat, THashFunc >::Save(), TBigNet< TNodeData, IsDir >::SaveToDisk(), and TLocClust::SupportSweep().

{return KeyDatV.Len()-FreeKeys;}

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
void THash< TKey, TDat, THashFunc >::Load ( TSIn SIn) [inline]

Definition at line 134 of file hash.h.

Referenced by TUniCaseFolding::Load(), TUniChDb::Load(), and TBigNet< TNodeData, IsDir >::LoadNodeDatH().

                      {
    PortV.Load(SIn); KeyDatV.Load(SIn);
    AutoSizeP=TBool(SIn); FFreeKeyId=TInt(SIn); FreeKeys=TInt(SIn);
    SIn.LoadCs();}

Here is the caller graph for this function:

template<class TKey , class TDat , class THashFunc >
void THash< TKey, TDat, THashFunc >::LoadXml ( const PXmlTok XmlTok,
const TStr Nm = "" 
)

Definition at line 127 of file xmlser.h.

References TVec< TVal >::Len(), XLoad, and XLoadHd.

                                                                                {
  XLoadHd(Nm); TVec<THashKeyDat<TKey, TDat> > KeyDatV; XLoad(KeyDatV); XLoad(AutoSizeP);
        for (int KeyDatN=0; KeyDatN<KeyDatV.Len(); KeyDatN++){
                AddDat(KeyDatV[KeyDatN].Key, KeyDatV[KeyDatN].Dat);}}

Here is the call graph for this function:

template<class TKey, class TDat , class THashFunc >
void THash< TKey, TDat, THashFunc >::MarkDelKey ( const TKey &  Key)

Definition at line 376 of file hash.h.

References GetPrimHashCd(), GetSecHashCd(), IAssert, IAssertR, and PortN.

Referenced by THash< TInt, TEdge >::MarkDelKeyId().

                                                            {
  // MarkDelKey is same as Delkey expect last two lines
  IAssert(!PortV.Empty());
  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) && (KeyDatV[KeyId].Key==Key))){
    PrevKeyId=KeyId; KeyId=KeyDatV[KeyId].Next;}
  IAssertR(KeyId!=-1, Key.GetStr());
  if (PrevKeyId==-1){PortV[PortN]=KeyDatV[KeyId].Next;}
  else {KeyDatV[PrevKeyId].Next=KeyDatV[KeyId].Next;}
  KeyDatV[KeyId].Next=FFreeKeyId; FFreeKeyId=KeyId; FreeKeys++;
  KeyDatV[KeyId].HashCd=TInt(-1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
void THash< TKey, TDat, THashFunc >::MarkDelKeyId ( const int &  KeyId) [inline]

Definition at line 204 of file hash.h.

{MarkDelKey(GetKey(KeyId));}
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
TDat& THash< TKey, TDat, THashFunc >::operator() ( const TKey &  Key) [inline]

Definition at line 154 of file hash.h.

{return AddDat(Key);}
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
bool THash< TKey, TDat, THashFunc >::operator< ( const THash< TKey, TDat, THashFunc > &  Hash) const [inline]

Definition at line 151 of file hash.h.

{ Fail; return true; }
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
THash& THash< TKey, TDat, THashFunc >::operator= ( const THash< TKey, TDat, THashFunc > &  Hash) [inline]

Definition at line 145 of file hash.h.

                                     {
    if (this!=&Hash){
      PortV=Hash.PortV; KeyDatV=Hash.KeyDatV; AutoSizeP=Hash.AutoSizeP;
      FFreeKeyId=Hash.FFreeKeyId; FreeKeys=Hash.FreeKeys;}
    return *this;}
template<class TKey , class TDat , class THashFunc >
bool THash< TKey, TDat, THashFunc >::operator== ( const THash< TKey, TDat, THashFunc > &  Hash) const

Definition at line 300 of file hash.h.

References THash< TKey, TDat, THashFunc >::GetDat(), THash< TKey, TDat, THashFunc >::IsKey(), Len(), and THash< TKey, TDat, THashFunc >::Len().

                                                                     {
  if (Len() != Hash.Len()) { return false; }
  for (int i = FFirstKeyId(); FNextKeyId(i); ) {
    const TKey& Key = GetKey(i);
    if (! Hash.IsKey(Key)) { return false; }
    if (GetDat(Key) != Hash.GetDat(Key)) { return false; }
  }
  return true;
}

Here is the call graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
const TDat& THash< TKey, TDat, THashFunc >::operator[] ( const int &  KeyId) const [inline]

Definition at line 152 of file hash.h.

{return GetHashKeyDat(KeyId).Dat;}
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
TDat& THash< TKey, TDat, THashFunc >::operator[] ( const int &  KeyId) [inline]

Definition at line 153 of file hash.h.

{return GetHashKeyDat(KeyId).Dat;}
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
void THash< TKey, TDat, THashFunc >::Pack ( ) [inline]

Definition at line 239 of file hash.h.

Referenced by TUNGraph::Defrag(), and TGHash< TUInt64 >::Pack().

Here is the caller graph for this function:

template<class TKey , class TDat , class THashFunc >
void THash< TKey, TDat, THashFunc >::Resize ( ) [private]

Definition at line 269 of file hash.h.

References GetPrimHashCd(), THashKeyDat< TKey, TDat >::HashCd, THashKeyDat< TKey, TDat >::Key, THashKeyDat< TKey, TDat >::Next, and PortN.

                                         {
  // resize & initialize port vector
  //if (PortV.Len()==0){PortV.Gen(17);}
  //else {PortV.Gen(2*PortV.Len()+1);}
  if (PortV.Len()==0){
    PortV.Gen(17);
  } else if (AutoSizeP&&(KeyDatV.Len()>2*PortV.Len())){
    PortV.Gen(GetNextPrime(PortV.Len()+1));
  } else {
    return;
  }
  PortV.PutAll(TInt(-1));
  // rehash keys
  for (int KeyId=0; KeyId<KeyDatV.Len(); KeyId++){
    THKeyDat& KeyDat=KeyDatV[KeyId];
    if (KeyDat.HashCd!=-1){
      const int PortN = abs(THashFunc::GetPrimHashCd(KeyDat.Key) % PortV.Len());
      KeyDat.Next=PortV[PortN];
      PortV[PortN]=KeyId;
    }
  }
}

Here is the call graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
void THash< TKey, TDat, THashFunc >::Save ( TSOut SOut) const [inline]
template<class TKey , class TDat , class THashFunc >
void THash< TKey, TDat, THashFunc >::SaveXml ( TSOut SOut,
const TStr Nm 
)

Definition at line 133 of file xmlser.h.

References XSave, and XSaveHd.

template<class TKey , class TDat , class THashFunc >
void THash< TKey, TDat, THashFunc >::Sort ( const bool &  CmpKey,
const bool &  Asc 
)

Definition at line 520 of file hash.h.

References IAssertR, Len(), THashKeyDat< TKey, TDat >::Next, and Next().

Referenced by TLocClustStat::Run(), THash< TInt, TEdge >::SortByDat(), and THash< TInt, TEdge >::SortByKey().

                                                                           {
  IAssertR(IsKeyIdEqKeyN(), "THash::Sort only works when table has no deleted keys.");
  TIntV TargV(Len()), MapV(Len()), StateV(Len());
  for (int i = 0; i < TargV.Len(); i++) {
    TargV[i] = i; MapV[i] = i; StateV[i] = i;
  }
  // sort KeyIds
  THashKeyDatCmp HashCmp(*this, CmpKey, Asc);
  TargV.SortCmp(HashCmp);
  // now sort the update vector
  THashKeyDat<TKey, TDat> Tmp;
  for (int i = 0; i < TargV.Len()-1; i++) {
    const int SrcPos = MapV[TargV[i]];
    const int Loc = i;
    // swap data
    Tmp = KeyDatV[SrcPos];
    KeyDatV[SrcPos] = KeyDatV[Loc];
    KeyDatV[Loc] = Tmp;
    // swap keys
    MapV[StateV[i]] = SrcPos;
    StateV.Swap(Loc, SrcPos);
  }
  for (int i = 0; i < TargV.Len(); i++) {
    MapV[TargV[i]] = i; }
  for (int p = 0; p < PortV.Len(); p++) {
    if (PortV[p] != -1) {
      PortV[p] = MapV[PortV[p]]; } }
  for (int i = 0; i < KeyDatV.Len(); i++) {
    if (KeyDatV[i].Next != -1) {
      KeyDatV[i].Next = MapV[KeyDatV[i].Next]; }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
void THash< TKey, TDat, THashFunc >::SortByDat ( const bool &  Asc = true) [inline]
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
void THash< TKey, TDat, THashFunc >::SortByKey ( const bool &  Asc = true) [inline]
template<class TKey , class TDat , class THashFunc >
void THash< TKey, TDat, THashFunc >::Swap ( THash< TKey, TDat, THashFunc > &  Hash)

Definition at line 494 of file hash.h.

References THash< TKey, TDat, THashFunc >::AutoSizeP, THash< TKey, TDat, THashFunc >::FFreeKeyId, THash< TKey, TDat, THashFunc >::FreeKeys, THash< TKey, TDat, THashFunc >::KeyDatV, THash< TKey, TDat, THashFunc >::PortV, and Swap().

Referenced by TSnap::GetShortPath().

                                                   {
  if (this!=&Hash){
    PortV.Swap(Hash.PortV);
    KeyDatV.Swap(Hash.KeyDatV);
    ::Swap(AutoSizeP, Hash.AutoSizeP);
    ::Swap(FFreeKeyId, Hash.FFreeKeyId);
    ::Swap(FreeKeys, Hash.FreeKeys);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
TBool THash< TKey, TDat, THashFunc >::AutoSizeP [private]
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
TInt THash< TKey, TDat, THashFunc >::FFreeKeyId [private]
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
TInt THash< TKey, TDat, THashFunc >::FreeKeys [private]
template<class TKey, class TDat, class THashFunc = TDefaultHashFunc<TKey>>
const unsigned int THash< TKey, TDat, THashFunc >::HashPrimeT [static]
Initial value:
{
  3ul, 5ul, 11ul, 23ul,
  53ul,         97ul,         193ul,       389ul,       769ul,
  1543ul,       3079ul,       6151ul,      12289ul,     24593ul,
  49157ul,      98317ul,      196613ul,    393241ul,    786433ul,
  1572869ul,    3145739ul,    6291469ul,   12582917ul,  25165843ul,
  50331653ul,   100663319ul,  201326611ul, 402653189ul, 805306457ul,
  1610612741ul, 3221225473ul, 4294967291ul
}

Definition at line 88 of file hash.h.


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