SNAP Library , Developer Reference  2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
THashSet< TKey, THashFunc > Class Template Reference

#include <shash.h>

Collaboration diagram for THashSet< TKey, THashFunc >:

List of all members.

Public Types

typedef THashSetKeyI< TKey > TIter

Public Member Functions

 THashSet ()
 THashSet (const THashSet &Set)
 THashSet (const int &ExpectVals, const bool &_AutoSizeP=false)
 THashSet (const TVec< TKey > &KeyV)
 THashSet (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)
THashSetoperator= (const THashSet &Set)
bool operator== (const THashSet &Set) const
const TKey & operator[] (const int &KeyId) const
TKey & operator[] (const int &KeyId)
::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)
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)
void AddKeyV (const TVec< TKey > &KeyV)
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
bool IsKey (const TKey &Key) const
bool IsKey (const TKey &Key, int &KeyId) const
bool IsKeyId (const int &KeyId) const
int FFirstKeyId () const
bool FNextKeyId (int &KeyId) const
void GetKeyV (TVec< TKey > &KeyV) const
void Swap (THashSet &Set)
void Defrag ()
void Pack ()

Static Public Member Functions

static THashSet< TKey > GetSet (const TKey &Key1)
static THashSet< TKey > GetSet (const TKey &Key1, const TKey &Key2)
static THashSet< TKey > GetSet (const TKey &Key1, const TKey &Key2, const TKey &Key3)
static THashSet< TKey > GetSet (const TKey &Key1, const TKey &Key2, const TKey &Key3, const TKey &Key4)
static THashSet< TKey > GetSet (const TKey &Key1, const TKey &Key2, const TKey &Key3, const TKey &Key4, const TKey &Key5)
static THashSet< TKey > GetSet (const TKey &Key1, const TKey &Key2, const TKey &Key3, const TKey &Key4, const TKey &Key5, const TKey &Key6)
static THashSet< TKey > GetSet (const TKey &Key1, const TKey &Key2, const TKey &Key3, const TKey &Key4, const TKey &Key5, const TKey &Key6, const TKey &Key7)
static THashSet< TKey > GetSet (const TKey &Key1, const TKey &Key2, const TKey &Key3, const TKey &Key4, const TKey &Key5, const TKey &Key6, const TKey &Key7, const TKey &Key8)
static THashSet< TKey > GetSet (const TKey &Key1, const TKey &Key2, const TKey &Key3, const TKey &Key4, const TKey &Key5, const TKey &Key6, const TKey &Key7, const TKey &Key8, const TKey &Key9)

Private Types

typedef THashSetKey< TKey > TSetKey

Private Member Functions

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

Private Attributes

TIntV PortV
TVec< TSetKeyKeyV
TBool AutoSizeP
TInt FFreeKeyId
TInt FreeKeys

Detailed Description

template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
class THashSet< TKey, THashFunc >

Definition at line 1040 of file shash.h.


Member Typedef Documentation

template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
typedef THashSetKeyI<TKey> THashSet< TKey, THashFunc >::TIter

Definition at line 1042 of file shash.h.

template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
typedef THashSetKey<TKey> THashSet< TKey, THashFunc >::TSetKey [private]

Definition at line 1044 of file shash.h.


Constructor & Destructor Documentation

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

Definition at line 1059 of file shash.h.

            :
    PortV(), KeyV(),
    AutoSizeP(true), FFreeKeyId(-1), FreeKeys(0) { }
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
THashSet< TKey, THashFunc >::THashSet ( const THashSet< TKey, THashFunc > &  Set) [inline]

Definition at line 1062 of file shash.h.

template<class TKey , class THashFunc >
THashSet< TKey, THashFunc >::THashSet ( const int &  ExpectVals,
const bool &  _AutoSizeP = false 
)

Definition at line 1210 of file shash.h.

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

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

Here is the call graph for this function:

template<class TKey, class THashFunc >
THashSet< TKey, THashFunc >::THashSet ( const TVec< TKey > &  KeyV) [explicit]

Definition at line 1217 of file shash.h.

References THashSet< TKey, THashFunc >::AddKey(), TVec< TVal >::Len(), THashSet< TKey, THashFunc >::PortV, and TVec< TVal >::PutAll().

                                                           :
 PortV(GetNextPrime(_KeyV.Len()/2+1)), KeyV(_KeyV.Len(), 0),
 AutoSizeP(false), FFreeKeyId(-1), FreeKeys(0) {
  PortV.PutAll(TInt(-1));
  for (int i = 0; i < _KeyV.Len(); i++) {
    AddKey(_KeyV[i]);
  }
}

Here is the call graph for this function:

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

Definition at line 1067 of file shash.h.

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

Member Function Documentation

template<class TKey, class THashFunc >
int THashSet< TKey, THashFunc >::AddKey ( const TKey &  Key)

Definition at line 1247 of file shash.h.

Referenced by TLocClustStat::BagOfWhiskers(), TUndirFFire::BurnGeoFire(), TNetConstraint< PGraph >::CalcConstraints(), TSnap::CntEdgesToSet(), TSnap::CntUniqDirEdges(), TSnap::CntUniqUndirEdges(), TSnap::ConvertGraph(), TSnap::TSnapDetail::TGetSubGraph< PGraph, false >::Do(), TSnap::TSnapDetail::TConvertSubGraph< POutGraph, PInGraph, IsMultiGraph >::Do(), TSnap::TSnapDetail::TConvertSubGraph< POutGraph, PInGraph, false >::Do(), TArtPointVisitor::FinishNode(), TBiConVisitor::FinishNode(), TSnap::GenConfModel(), TSnap::GenPrefAttach(), TSnap::GenRewire(), TSnap::GenSmallWorld(), TSnap::Get1CnCom(), TSnap::Get1CnComSzCnt(), TTimeNENet::Get1stEdgeNet(), TSnap::GetCmnNbrs(), TLocClust::GetCutStat(), TSnap::GetEdgeBridges(), TSnap::GetEdgesInOut(), TLocClustStat::TCutInfo::GetFracDegOut(), TCliqueOverlap::GetIntersection(), TCliqueOverlap::GetMaximalCliques(), TSnap::GetModularity(), TCliqueOverlap::GetNbrs(), TSnap::GetNodeTriads(), TTimeNENet::GetPrefAttach(), TCliqueOverlap::GetRelativeComplement(), THashSet< TInt >::GetSet(), TSnap::GetSubGraph(), TBigNet< TNodeData, IsDir >::GetSubGraph(), TSnap::GetTriadEdges(), TSnap::GetTriads(), TNodeEdgeNet< TNodeData, TEdgeData >::GetUniqEdges(), TSnap::GetWccs(), TSnap::GetWccSzCnt(), TSnap::LoadDyNet(), TSnap::LoadDyNetGraphV(), THashSet< TInt >::LoadXml(), TLocClustStat::PlotNCPScatter(), TGnuPlot::PlotValMomH(), TAGM::RndConnectInsideCommunity(), TLocClustStat::Run(), TTimeNENet::SaveEdgeTm(), TSnap::SaveMatlabSparseMtx(), TGStatVec::SaveTxt(), TGraphKey::TakeGraph(), and THashSet< TKey, THashFunc >::THashSet().

                                                     {
  if ((KeyV.Len()>2*PortV.Len())||PortV.Empty()) {Resize(); }
  int PortN=abs(THashFunc::GetPrimHashCd(Key)%PortV.Len());
  int HashCd=abs(THashFunc::GetSecHashCd(Key));
  int PrevKeyId=-1;
  int KeyId=PortV[PortN];

  while ((KeyId!=-1) &&
   !((KeyV[KeyId].HashCd==HashCd) && (KeyV[KeyId].Key==Key))) {
    PrevKeyId=KeyId; KeyId=KeyV[KeyId].Next; }

  if (KeyId==-1) {
    if (FFreeKeyId==-1) {
      KeyId=KeyV.Add(TSetKey(-1, HashCd, Key));
    } else {
      KeyId=FFreeKeyId; FFreeKeyId=KeyV[FFreeKeyId].Next; FreeKeys--;
      KeyV[KeyId].Next = -1;
      KeyV[KeyId].HashCd = HashCd;
      KeyV[KeyId].Key = Key;
    }
    if (PrevKeyId==-1) {
      PortV[PortN]=KeyId;
    } else {
      KeyV[PrevKeyId].Next=KeyId;
    }
  }
  return KeyId;
}

Here is the caller graph for this function:

template<class TKey, class THashFunc >
void THashSet< TKey, THashFunc >::AddKeyV ( const TVec< TKey > &  KeyV)

Definition at line 1277 of file shash.h.

References TVec< TVal >::Len().

Referenced by TCliqueOverlap::GetCPMCommunities().

                                                              {
  for (int i = 0; i < KeyV.Len(); i++) { AddKey(KeyV[i]); }
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
TIter THashSet< TKey, THashFunc >::BegI ( ) const [inline]

Definition at line 1098 of file shash.h.

Referenced by TCliqueOverlap::GetIntersection(), TCliqueOverlap::GetNodeIdWithMaxDeg(), TCliqueOverlap::GetRelativeComplement(), TCliqueOverlap::Intersection(), and TCliqueOverlap::MaxNbrsInCANDNodeId().

                     {
    if (Len()>0) {
      if (IsKeyIdEqKeyN()) { return TIter(KeyV.BegI(), KeyV.EndI()); }
      int FKeyId=-1;  FNextKeyId(FKeyId);
      return TIter(KeyV.BegI()+FKeyId, KeyV.EndI()); }
    return TIter(KeyV.EndI(), KeyV.EndI());
  }

Here is the caller graph for this function:

template<class TKey , class THashFunc >
void THashSet< TKey, THashFunc >::Clr ( const bool &  DoDel = true,
const int &  NoDelLim = -1 
)
template<class TKey , class THashFunc >
void THashSet< TKey, THashFunc >::Defrag ( )

Definition at line 1359 of file shash.h.

References IAssert.

Referenced by TSnap::TSnapDetail::TGetSubGraph< PGraph, false >::Do(), and THashSet< TInt >::SaveXml().

                                       {
  if (!IsKeyIdEqKeyN()) {
    THashSet<TKey> Set(PortV.Len());
    int KeyId=FFirstKeyId(); TKey Key;
    while (FNextKeyId(KeyId)) {
      GetKey(KeyId, Key);
      Set.AddKey(Key);
    }
    Pack();
    operator=(Set);
    IAssert(IsKeyIdEqKeyN());
  }
}

Here is the caller graph for this function:

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

Definition at line 1125 of file shash.h.

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

Definition at line 1282 of file shash.h.

References IAssert, and IAssertR.

Referenced by THashSet< TInt >::DelKeyId(), and TCliqueOverlap::Expand().

                                                      {
  IAssert(!PortV.Empty());
  int PortN=abs(THashFunc::GetPrimHashCd(Key)%PortV.Len());
  int HashCd=abs(THashFunc::GetSecHashCd(Key));
  int PrevKeyId=-1;
  int KeyId=PortV[PortN];

  while ((KeyId!=-1) &&
   !((KeyV[KeyId].HashCd==HashCd) && (KeyV[KeyId].Key==Key))) {
    PrevKeyId=KeyId; KeyId=KeyV[KeyId].Next; }

  IAssertR(KeyId!=-1, Key.GetStr());
  if (PrevKeyId==-1) {PortV[PortN]=KeyV[KeyId].Next; }
  else {KeyV[PrevKeyId].Next=KeyV[KeyId].Next; }
  KeyV[KeyId].Next=FFreeKeyId; FFreeKeyId=KeyId; FreeKeys++;
  KeyV[KeyId].HashCd=TInt(-1);
  KeyV[KeyId].Key=TKey();
}

Here is the caller graph for this function:

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

Definition at line 1127 of file shash.h.

Referenced by THashSet< TInt >::DelIfKey(), THashSet< TInt >::DelKeyIdV(), and TSnap::GenRewire().

{DelKey(GetKey(KeyId)); }

Here is the caller graph for this function:

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

Definition at line 1128 of file shash.h.

                                      {
    for (int KeyIdN=0; KeyIdN<KeyIdV.Len(); KeyIdN++) {DelKeyId(KeyIdV[KeyIdN]); }}
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
bool THashSet< TKey, THashFunc >::Empty ( ) const [inline]

Definition at line 1113 of file shash.h.

Referenced by TSnap::GetNodeTriads(), and TLocClustStat::Run().

{return Len()==0; }

Here is the caller graph for this function:

template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
TIter THashSet< TKey, THashFunc >::EndI ( ) const [inline]
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
int THashSet< TKey, THashFunc >::FFirstKeyId ( ) const [inline]

Definition at line 1147 of file shash.h.

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

Definition at line 1334 of file shash.h.

Referenced by THashSet< TInt >::BegI().

                                                           {
  do {KeyId++; } while ((KeyId<KeyV.Len())&&(KeyV[KeyId].HashCd==-1));
  return KeyId<KeyV.Len();
}

Here is the caller graph for this function:

template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
void THashSet< TKey, THashFunc >::Gen ( const int &  ExpectVals) [inline]

Definition at line 1108 of file shash.h.

Referenced by TBigNet< TNodeData, IsDir >::GetSubGraph(), TSnap::GetWccs(), and TTimeNENet::SaveEdgeTm().

                                  {
    PortV.Gen(GetNextPrime(ExpectVals/2)); KeyV.Gen(ExpectVals, 0);
    FFreeKeyId=-1; FreeKeys=0; PortV.PutAll(TInt(-1)); }

Here is the caller graph for this function:

template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
TIter THashSet< TKey, THashFunc >::GetI ( const TKey &  Key) const [inline]

Definition at line 1106 of file shash.h.

{return TIter(&KeyV[GetKeyId(Key)], KeyV.EndI()); }
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
const TKey& THashSet< TKey, THashFunc >::GetKey ( const int &  KeyId) const [inline]

Definition at line 1134 of file shash.h.

Referenced by THashSet< TInt >::DelKeyId(), TSnap::GetNodeTriads(), TSnap::GetTriads(), and THashSet< TInt >::MarkDelKeyId().

                                             {
    return GetSetKey(KeyId).Key; }

Here is the caller graph for this function:

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

Definition at line 1321 of file shash.h.

Referenced by THashSet< TInt >::GetI(), TBigNet< TNodeData, IsDir >::GetSubGraph(), THashSet< TInt >::IsKey(), TSnap::LoadDyNet(), TSnap::LoadDyNetGraphV(), TTimeNENet::SaveEdgeTm(), and TGraphKey::TakeGraph().

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

  while ((KeyId!=-1) &&
   !((KeyV[KeyId].HashCd==HashCd) && (KeyV[KeyId].Key==Key))) {
    KeyId=KeyV[KeyId].Next; }
  return KeyId;
}

Here is the caller graph for this function:

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

Definition at line 1340 of file shash.h.

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

Referenced by TBiConVisitor::FinishNode(), TCliqueOverlap::GetCPMCommunities(), TSnap::GetEdgeBridges(), TLocClustStat::PlotNCPScatter(), and TGStatVec::SaveTxt().

                                                              {
  KeyV.Clr();
  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 THashFunc = TDefaultHashFunc<TKey>>
::TSize THashSet< TKey, THashFunc >::GetMemUsed ( ) const [inline]

Definition at line 1095 of file shash.h.

                           {
    return PortV.GetMemUsed() + KeyV.GetMemUsed() + sizeof(bool) + 2*sizeof(int); }
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
int THashSet< TKey, THashFunc >::GetMxKeyIds ( ) const [inline]

Definition at line 1117 of file shash.h.

{return KeyV.Len(); }
template<class TKey , class THashFunc >
uint THashSet< TKey, THashFunc >::GetNextPrime ( const uint Val) const [private]

Definition at line 1177 of file shash.h.

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

Referenced by THashSet< TInt >::Gen().

                                                                  {
  uint* f=(uint*)TIntH::HashPrimeT, *m, *l=(uint*)TIntH::HashPrimeT + (int)TIntH::HashPrimes;
  int h, len = (int)TIntH::HashPrimes;
  while (len > 0) {
    h = len >> 1;  m = f + h;
    if (*m < Val) { f = m;  f++;  len = len - h - 1; }
    else len = h;
  }
  return f == l ? *(l - 1) : *f;
}

Here is the caller graph for this function:

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

Definition at line 1115 of file shash.h.

{return PortV.Len(); }
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
int THashSet< TKey, THashFunc >::GetReservedKeyIds ( ) const [inline]

Definition at line 1118 of file shash.h.

{ return KeyV.Reserved(); }
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
int THashSet< TKey, THashFunc >::GetRndKeyId ( TRnd Rnd) const [inline]

Definition at line 1137 of file shash.h.

Referenced by TSnap::GenRewire().

                                   {
    IAssert(IsKeyIdEqKeyN());
    IAssert(Len()>0);
    return Rnd.GetUniDevInt(Len()); }

Here is the caller graph for this function:

template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
static THashSet<TKey> THashSet< TKey, THashFunc >::GetSet ( const TKey &  Key1) [inline, static]

Definition at line 1155 of file shash.h.

                                                {
        THashSet<TKey> Set(1); Set.AddKey(Key1); return Set;}
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
static THashSet<TKey> THashSet< TKey, THashFunc >::GetSet ( const TKey &  Key1,
const TKey &  Key2 
) [inline, static]

Definition at line 1157 of file shash.h.

                                                                  {
    THashSet<TKey> Set(2); Set.AddKey(Key1); Set.AddKey(Key2); return Set;}
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
static THashSet<TKey> THashSet< TKey, THashFunc >::GetSet ( const TKey &  Key1,
const TKey &  Key2,
const TKey &  Key3 
) [inline, static]

Definition at line 1159 of file shash.h.

                                                                                    {
    THashSet<TKey> Set(3); Set.AddKey(Key1); Set.AddKey(Key2); Set.AddKey(Key3); return Set;}
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
static THashSet<TKey> THashSet< TKey, THashFunc >::GetSet ( const TKey &  Key1,
const TKey &  Key2,
const TKey &  Key3,
const TKey &  Key4 
) [inline, static]

Definition at line 1161 of file shash.h.

                                                                                                      {
    THashSet<TKey> Set(4); Set.AddKey(Key1); Set.AddKey(Key2); Set.AddKey(Key3); Set.AddKey(Key4); return Set;}
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
static THashSet<TKey> THashSet< TKey, THashFunc >::GetSet ( const TKey &  Key1,
const TKey &  Key2,
const TKey &  Key3,
const TKey &  Key4,
const TKey &  Key5 
) [inline, static]

Definition at line 1163 of file shash.h.

                                                                                                                        {
    THashSet<TKey> Set(5); Set.AddKey(Key1); Set.AddKey(Key2); Set.AddKey(Key3); Set.AddKey(Key4); Set.AddKey(Key5); return Set;}
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
static THashSet<TKey> THashSet< TKey, THashFunc >::GetSet ( const TKey &  Key1,
const TKey &  Key2,
const TKey &  Key3,
const TKey &  Key4,
const TKey &  Key5,
const TKey &  Key6 
) [inline, static]

Definition at line 1165 of file shash.h.

                                                                                                                                          {
    THashSet<TKey> Set(6); Set.AddKey(Key1); Set.AddKey(Key2); Set.AddKey(Key3); Set.AddKey(Key4); Set.AddKey(Key5); Set.AddKey(Key6); return Set;}
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
static THashSet<TKey> THashSet< TKey, THashFunc >::GetSet ( const TKey &  Key1,
const TKey &  Key2,
const TKey &  Key3,
const TKey &  Key4,
const TKey &  Key5,
const TKey &  Key6,
const TKey &  Key7 
) [inline, static]

Definition at line 1167 of file shash.h.

                                                                                                                                                            {
    THashSet<TKey> Set(7); Set.AddKey(Key1); Set.AddKey(Key2); Set.AddKey(Key3); Set.AddKey(Key4); Set.AddKey(Key5); Set.AddKey(Key6); Set.AddKey(Key7); return Set;}
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
static THashSet<TKey> THashSet< TKey, THashFunc >::GetSet ( const TKey &  Key1,
const TKey &  Key2,
const TKey &  Key3,
const TKey &  Key4,
const TKey &  Key5,
const TKey &  Key6,
const TKey &  Key7,
const TKey &  Key8 
) [inline, static]

Definition at line 1169 of file shash.h.

                                                                                                                                                                              {
    THashSet<TKey> Set(8); Set.AddKey(Key1); Set.AddKey(Key2); Set.AddKey(Key3); Set.AddKey(Key4); Set.AddKey(Key5); Set.AddKey(Key6); Set.AddKey(Key7); Set.AddKey(Key8); return Set;}
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
static THashSet<TKey> THashSet< TKey, THashFunc >::GetSet ( const TKey &  Key1,
const TKey &  Key2,
const TKey &  Key3,
const TKey &  Key4,
const TKey &  Key5,
const TKey &  Key6,
const TKey &  Key7,
const TKey &  Key8,
const TKey &  Key9 
) [inline, static]

Definition at line 1171 of file shash.h.

                                                                                                                                                                                                {
    THashSet<TKey> Set(9); Set.AddKey(Key1); Set.AddKey(Key2); Set.AddKey(Key3); Set.AddKey(Key4); Set.AddKey(Key5); Set.AddKey(Key6); Set.AddKey(Key7); Set.AddKey(Key8); Set.AddKey(Key9); return Set;}
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
TSetKey& THashSet< TKey, THashFunc >::GetSetKey ( const int &  KeyId) [inline, private]

Definition at line 1050 of file shash.h.

Referenced by THashSet< TInt >::GetKey(), and THashSet< TInt >::operator[]().

                                       {
    TSetKey& SetKey=KeyV[KeyId];
    Assert(SetKey.HashCd!=-1); return SetKey; }

Here is the caller graph for this function:

template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
const TSetKey& THashSet< TKey, THashFunc >::GetSetKey ( const int &  KeyId) const [inline, private]

Definition at line 1053 of file shash.h.

                                                   {
    const TSetKey& SetKey=KeyV[KeyId];
    Assert(SetKey.HashCd!=-1); return SetKey; }
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
bool THashSet< TKey, THashFunc >::IsAutoSize ( ) const [inline]

Definition at line 1116 of file shash.h.

{return AutoSizeP; }
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
bool THashSet< TKey, THashFunc >::IsKey ( const TKey &  Key,
int &  KeyId 
) const [inline]

Definition at line 1142 of file shash.h.

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

Definition at line 1144 of file shash.h.

                                       {
    return (0<=KeyId)&&(KeyId<KeyV.Len())&&(KeyV[KeyId].HashCd!=-1); }
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
bool THashSet< TKey, THashFunc >::IsKeyIdEqKeyN ( ) const [inline]

Definition at line 1119 of file shash.h.

Referenced by THashSet< TInt >::BegI(), and THashSet< TInt >::GetRndKeyId().

{return FreeKeys==0; }

Here is the caller graph for this function:

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

Definition at line 1071 of file shash.h.

                       {
    PortV.Load(SIn); KeyV.Load(SIn);
    AutoSizeP=TBool(SIn); FFreeKeyId=TInt(SIn); FreeKeys=TInt(SIn);
    SIn.LoadCs(); }
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
void THashSet< TKey, THashFunc >::LoadXml ( const PXmlTok XmlTok,
const TStr Nm = "" 
) [inline]

Definition at line 1079 of file shash.h.

                                                         {
    XLoadHd(Nm); TVec<TSetKey> KeyV; XLoad(KeyV); XLoad(AutoSizeP);
    for (int KeyN=0; KeyN<KeyV.Len(); KeyN++) {
      AddKey(KeyV[KeyN].Key); }}
template<class TKey, class THashFunc >
void THashSet< TKey, THashFunc >::MarkDelKey ( const TKey &  Key)

Definition at line 1302 of file shash.h.

References IAssert, and IAssertR.

Referenced by THashSet< TInt >::MarkDelKeyId().

                                                          {
  IAssert(!PortV.Empty());
  int PortN=abs(THashFunc::GetPrimHashCd(Key)%PortV.Len());
  int HashCd=abs(THashFunc::GetSecHashCd(Key));
  int PrevKeyId=-1;
  int KeyId=PortV[PortN];

  while ((KeyId!=-1) &&
   !((KeyV[KeyId].HashCd==HashCd) && (KeyV[KeyId].Key==Key))) {
    PrevKeyId=KeyId; KeyId=KeyV[KeyId].Next; }

  IAssertR(KeyId!=-1, Key.GetStr());
  if (PrevKeyId==-1) {PortV[PortN]=KeyV[KeyId].Next; }
  else {KeyV[PrevKeyId].Next=KeyV[KeyId].Next; }
  KeyV[KeyId].Next=FFreeKeyId; FFreeKeyId=KeyId; FreeKeys++;
  KeyV[KeyId].HashCd=TInt(-1);
}

Here is the caller graph for this function:

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

Definition at line 1132 of file shash.h.

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

Definition at line 1086 of file shash.h.

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

Definition at line 1227 of file shash.h.

References THashSet< TKey, THashFunc >::IsKey(), and THashSet< TKey, THashFunc >::Len().

                                                                    {
  if (Len() != Set.Len()) { return false; }
  for (int k = FFirstKeyId(); FNextKeyId(k); k++) {
    if (! Set.IsKey(GetKey(k))) { return false; }
  }
  return true;
}

Here is the call graph for this function:

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

Definition at line 1092 of file shash.h.

{return GetSetKey(KeyId).Key; }
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
TKey& THashSet< TKey, THashFunc >::operator[] ( const int &  KeyId) [inline]

Definition at line 1093 of file shash.h.

{return GetSetKey(KeyId).Key; }
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
void THashSet< TKey, THashFunc >::Pack ( ) [inline]

Definition at line 1153 of file shash.h.

{KeyV.Pack(); }
template<class TKey , class THashFunc >
void THashSet< TKey, THashFunc >::Resize ( ) [private]

Definition at line 1189 of file shash.h.

References THashSetKey< TKey >::HashCd, THashSetKey< TKey >::Key, and THashSetKey< TKey >::Next.

                                       {
  // resize & initialize port vector
  if (PortV.Len()==0) {PortV.Gen(17); }
  else if (AutoSizeP&&(KeyV.Len()>2*PortV.Len())) {
    PortV.Gen(GetNextPrime(PortV.Len()+1));
  } else {
    return;
  }
  PortV.PutAll(TInt(-1));
  // reSet keys
  for (int KeyId=0; KeyId<KeyV.Len(); KeyId++) {
    TSetKey& SetKey=KeyV[KeyId];
    if (SetKey.HashCd!=-1) {
      int PortN=abs(THashFunc::GetPrimHashCd(SetKey.Key)%PortV.Len());
      SetKey.Next=PortV[PortN];
      PortV[PortN]=KeyId;
    }
  }
}
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
void THashSet< TKey, THashFunc >::Save ( TSOut SOut) const [inline]

Definition at line 1075 of file shash.h.

                               {
    PortV.Save(SOut); KeyV.Save(SOut);
    AutoSizeP.Save(SOut); FFreeKeyId.Save(SOut); FreeKeys.Save(SOut);
    SOut.SaveCs(); }
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
void THashSet< TKey, THashFunc >::SaveXml ( TSOut SOut,
const TStr Nm 
) [inline]

Definition at line 1083 of file shash.h.

template<class TKey , class THashFunc >
void THashSet< TKey, THashFunc >::Swap ( THashSet< TKey, THashFunc > &  Set)

Member Data Documentation

template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
TBool THashSet< TKey, THashFunc >::AutoSizeP [private]
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
TInt THashSet< TKey, THashFunc >::FFreeKeyId [private]
template<class TKey, class THashFunc = TDefaultHashFunc<TKey>>
TInt THashSet< TKey, THashFunc >::FreeKeys [private]

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