SNAP Library , Developer Reference
2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <shash.h>
Public Types | |
typedef TSparseGroup< TVal, GroupSize > | TSGroup |
typedef TSparseTableI< TVal, GroupSize > | TIter |
Public Member Functions | |
TSparseTable (const int &MaxVals=0) | |
TSparseTable (const TSparseTable &ST) | |
TSparseTable (TSIn &SIn) | |
void | Load (TSIn &SIn) |
void | Save (TSOut &SOut) const |
TSparseTable & | operator= (const TSparseTable &ST) |
bool | operator== (const TSparseTable &ST) const |
bool | operator< (const TSparseTable &ST) const |
::TSize | GetMemUsed () const |
TIter | BegI () const |
TIter | EndI () const |
TIter | GetI (const int &ValN) const |
int | Len () const |
int | Reserved () const |
int | Groups () const |
bool | Empty () const |
uint | GetDiskSz () const |
void | Clr (const bool &DoDel=true) |
void | Reserve (const int NewVals) |
void | Resize (const int &NewVals) |
void | Swap (TSparseTable &ST) |
bool | IsEmpty (const int &ValN) const |
const TVal & | Get (const int &ValN) const |
TVal & | Set (const int &ValN, const TVal &Val) |
TVal & | Set (const int &ValN) |
void | Del (const int &ValN) |
TSGroup & | GetGroup (const int &GroupN) |
const TSGroup & | GetGroup (const int &GroupN) const |
Private Member Functions | |
int | PosInGroup (const int &ValN) const |
int | GroupNum (const int &ValN) const |
const TSGroup & | GetGrp1 (const int &ValN) const |
TSGroup & | GetGrp1 (const int &ValN) |
Static Private Member Functions | |
static int | GetGroups (const int &Vals) |
Private Attributes | |
TInt | MxVals |
TInt | Vals |
TVec< TSGroup > | GroupV |
typedef TSparseTableI<TVal, GroupSize> TSparseTable< TVal, GroupSize >::TIter |
typedef TSparseGroup<TVal, GroupSize> TSparseTable< TVal, GroupSize >::TSGroup |
TSparseTable< TVal, GroupSize >::TSparseTable | ( | const int & | MaxVals = 0 | ) | [inline] |
TSparseTable< TVal, GroupSize >::TSparseTable | ( | const TSparseTable< TVal, GroupSize > & | ST | ) | [inline] |
TSparseTable< TVal, GroupSize >::TSparseTable | ( | TSIn & | SIn | ) | [inline] |
TIter TSparseTable< TVal, GroupSize >::BegI | ( | ) | const [inline] |
Definition at line 336 of file shash.h.
Referenced by TSparseHash< TKey, TDat, GroupSize >::BegI(), and TSparseSet< TKey, GroupSize >::BegI().
{ if (Len() > 0) { int B = 0; while (B < Groups() && GroupV[B].Empty()) { B++; } return TIter(GroupV.BegI(), GroupV.BegI()+B, GroupV.EndI()); } return TIter(GroupV.BegI(), GroupV.EndI(), GroupV.EndI()); }
void TSparseTable< TVal, GroupSize >::Clr | ( | const bool & | DoDel = true | ) |
Definition at line 392 of file shash.h.
Referenced by TSparseHash< TKey, TDat, GroupSize >::Clr(), and TSparseSet< TKey, GroupSize >::Clr().
{ if (! DoDel) { for (int g = 0; g < GroupV.Len(); g++) GroupV[g].Clr(false); } else { MxVals = 0; GroupV.Clr(true); } Vals = 0; }
void TSparseTable< TVal, GroupSize >::Del | ( | const int & | ValN | ) |
Definition at line 440 of file shash.h.
References Assert, TSparseGroup< TVal, GroupSize >::Del(), and TSparseGroup< TVal, GroupSize >::Len().
{ Assert(ValN < MxVals); TSGroup& Group = GetGrp1(ValN); const int OldVals = Group.Len(); Group.Del(PosInGroup(ValN)); Vals += Group.Len() - OldVals; }
bool TSparseTable< TVal, GroupSize >::Empty | ( | ) | const [inline] |
Definition at line 352 of file shash.h.
Referenced by TSparseTable< THashKeyDat, GroupSize >::BegI().
{ return Vals == 0; }
TIter TSparseTable< TVal, GroupSize >::EndI | ( | ) | const [inline] |
const TVal& TSparseTable< TVal, GroupSize >::Get | ( | const int & | ValN | ) | const [inline] |
Definition at line 362 of file shash.h.
Referenced by TSparseHash< TKey, TDat, GroupSize >::GetDatKeyId(), TSparseHash< TKey, TDat, GroupSize >::GetKey(), and TSparseSet< TKey, GroupSize >::GetKey().
{ return GroupV[GroupNum(ValN)].Get(PosInGroup(ValN)); }
uint TSparseTable< TVal, GroupSize >::GetDiskSz | ( | ) | const [inline] |
Definition at line 353 of file shash.h.
Referenced by TSparseHash< TKey, TDat, GroupSize >::GetDiskSz(), and TSparseSet< TKey, GroupSize >::GetDiskSz().
TSGroup& TSparseTable< TVal, GroupSize >::GetGroup | ( | const int & | GroupN | ) | [inline] |
Definition at line 367 of file shash.h.
Referenced by TSparseHash< TKey, TDat, GroupSize >::CopyFrom(), TSparseSet< TKey, GroupSize >::CopyFrom(), TSparseHash< TKey, TDat, GroupSize >::MoveFrom(), and TSparseSet< TKey, GroupSize >::MoveFrom().
{ return GroupV[GroupN]; }
const TSGroup& TSparseTable< TVal, GroupSize >::GetGroup | ( | const int & | GroupN | ) | const [inline] |
static int TSparseTable< TVal, GroupSize >::GetGroups | ( | const int & | Vals | ) | [inline, static, private] |
const TSGroup& TSparseTable< TVal, GroupSize >::GetGrp1 | ( | const int & | ValN | ) | const [inline, private] |
TSGroup& TSparseTable< TVal, GroupSize >::GetGrp1 | ( | const int & | ValN | ) | [inline, private] |
TIter TSparseTable< TVal, GroupSize >::GetI | ( | const int & | ValN | ) | const [inline] |
Definition at line 343 of file shash.h.
Referenced by TSparseHash< TKey, TDat, GroupSize >::GetI(), and TSparseSet< TKey, GroupSize >::GetI().
{ Assert(! IsEmpty(ValN)); typedef typename TVec<TSGroup>::TIter TVIter; const TVIter GI = GroupV.GetI(GroupNum(ValN)); return TIter(GroupV.BegI(), GI, GroupV.EndI(), GI->PosToOffset(PosInGroup(ValN))); }
::TSize TSparseTable< TVal, GroupSize >::GetMemUsed | ( | ) | const [inline] |
Definition at line 334 of file shash.h.
Referenced by TSparseHash< TKey, TDat, GroupSize >::GetMemUsed(), and TSparseSet< TKey, GroupSize >::GetMemUsed().
{ return 2*sizeof(TInt)+Vals*sizeof(TVal)+GroupV.GetMemUsed(); }
int TSparseTable< TVal, GroupSize >::GroupNum | ( | const int & | ValN | ) | const [inline, private] |
Definition at line 320 of file shash.h.
Referenced by TSparseTable< THashKeyDat, GroupSize >::Get(), TSparseTable< THashKeyDat, GroupSize >::GetGrp1(), TSparseTable< THashKeyDat, GroupSize >::GetI(), and TSparseTable< THashKeyDat, GroupSize >::IsEmpty().
{ return ValN / GroupSize; }
int TSparseTable< TVal, GroupSize >::Groups | ( | ) | const [inline] |
Definition at line 351 of file shash.h.
Referenced by TSparseTable< THashKeyDat, GroupSize >::BegI(), TSparseHash< TKey, TDat, GroupSize >::CopyFrom(), TSparseSet< TKey, GroupSize >::CopyFrom(), TSparseTable< THashKeyDat, GroupSize >::GetDiskSz(), TSparseHash< TKey, TDat, GroupSize >::MoveFrom(), and TSparseSet< TKey, GroupSize >::MoveFrom().
bool TSparseTable< TVal, GroupSize >::IsEmpty | ( | const int & | ValN | ) | const [inline] |
Definition at line 361 of file shash.h.
Referenced by TSparseTable< THashKeyDat, GroupSize >::GetI(), TSparseHash< TKey, TDat, GroupSize >::IsKeyId(), and TSparseSet< TKey, GroupSize >::IsKeyId().
{ return GroupV[GroupNum(ValN)].IsEmpty(PosInGroup(ValN)); }
int TSparseTable< TVal, GroupSize >::Len | ( | ) | const [inline] |
Definition at line 349 of file shash.h.
Referenced by TSparseTable< THashKeyDat, GroupSize >::BegI(), TSparseHash< TKey, TDat, GroupSize >::Len(), and TSparseSet< TKey, GroupSize >::Len().
{ return Vals; }
void TSparseTable< TVal, GroupSize >::Load | ( | TSIn & | SIn | ) | [inline] |
Definition at line 328 of file shash.h.
Referenced by TSparseHash< TKey, TDat, GroupSize >::Load(), and TSparseSet< TKey, GroupSize >::Load().
bool TSparseTable< TVal, GroupSize >::operator< | ( | const TSparseTable< TVal, GroupSize > & | ST | ) | const |
Definition at line 387 of file shash.h.
References TSparseTable< TVal, GroupSize >::GroupV, and TSparseTable< TVal, GroupSize >::Vals.
TSparseTable< TVal, GroupSize > & TSparseTable< TVal, GroupSize >::operator= | ( | const TSparseTable< TVal, GroupSize > & | ST | ) |
Definition at line 372 of file shash.h.
References TSparseTable< TVal, GroupSize >::GroupV, TSparseTable< TVal, GroupSize >::MxVals, and TSparseTable< TVal, GroupSize >::Vals.
bool TSparseTable< TVal, GroupSize >::operator== | ( | const TSparseTable< TVal, GroupSize > & | ST | ) | const |
Definition at line 382 of file shash.h.
References TSparseTable< TVal, GroupSize >::GroupV, TSparseTable< TVal, GroupSize >::MxVals, and TSparseTable< TVal, GroupSize >::Vals.
int TSparseTable< TVal, GroupSize >::PosInGroup | ( | const int & | ValN | ) | const [inline, private] |
Definition at line 319 of file shash.h.
Referenced by TSparseTable< THashKeyDat, GroupSize >::Get(), TSparseTable< THashKeyDat, GroupSize >::GetI(), and TSparseTable< THashKeyDat, GroupSize >::IsEmpty().
{ return ValN % GroupSize; }
void TSparseTable< TVal, GroupSize >::Reserve | ( | const int | NewVals | ) | [inline] |
int TSparseTable< TVal, GroupSize >::Reserved | ( | ) | const [inline] |
Definition at line 350 of file shash.h.
Referenced by TSparseHash< TKey, TDat, GroupSize >::Reserved(), and TSparseSet< TKey, GroupSize >::Reserved().
{ return MxVals; }
void TSparseTable< TVal, GroupSize >::Resize | ( | const int & | NewVals | ) |
void TSparseTable< TVal, GroupSize >::Save | ( | TSOut & | SOut | ) | const [inline] |
Definition at line 329 of file shash.h.
Referenced by TSparseHash< TKey, TDat, GroupSize >::Save(), and TSparseSet< TKey, GroupSize >::Save().
TVal & TSparseTable< TVal, GroupSize >::Set | ( | const int & | ValN, |
const TVal & | Val | ||
) |
Definition at line 420 of file shash.h.
References Assert, TSparseGroup< TVal, GroupSize >::Len(), and TSparseGroup< TVal, GroupSize >::Set().
Referenced by TSparseHash< TKey, TDat, GroupSize >::GetDatKeyId().
{ Assert(ValN < MxVals); TSGroup& Group = GetGrp1(ValN); const int OldVals = Group.Len(); TVal& ValRef = Group.Set(PosInGroup(ValN), Val); Vals += Group.Len() - OldVals; return ValRef; }
TVal & TSparseTable< TVal, GroupSize >::Set | ( | const int & | ValN | ) |
Definition at line 430 of file shash.h.
References Assert, TSparseGroup< TVal, GroupSize >::Len(), and TSparseGroup< TVal, GroupSize >::Set().
{ Assert(ValN < MxVals); TSGroup& Group = GetGrp1(ValN); const int OldVals = Group.Len(); TVal& ValRef = Group.Set(PosInGroup(ValN)); Vals += Group.Len() - OldVals; return ValRef; }
void TSparseTable< TVal, GroupSize >::Swap | ( | TSparseTable< TVal, GroupSize > & | ST | ) |
Definition at line 413 of file shash.h.
References TSparseTable< TVal, GroupSize >::GroupV, TSparseTable< TVal, GroupSize >::MxVals, Swap(), and TSparseTable< TVal, GroupSize >::Vals.
TVec<TSGroup> TSparseTable< TVal, GroupSize >::GroupV [private] |
Definition at line 316 of file shash.h.
Referenced by TSparseTable< THashKeyDat, GroupSize >::BegI(), TSparseTable< THashKeyDat, GroupSize >::EndI(), TSparseTable< THashKeyDat, GroupSize >::Get(), TSparseTable< THashKeyDat, GroupSize >::GetGroup(), TSparseTable< THashKeyDat, GroupSize >::GetGrp1(), TSparseTable< THashKeyDat, GroupSize >::GetI(), TSparseTable< THashKeyDat, GroupSize >::GetMemUsed(), TSparseTable< THashKeyDat, GroupSize >::Groups(), TSparseTable< THashKeyDat, GroupSize >::IsEmpty(), TSparseTable< THashKeyDat, GroupSize >::Load(), TSparseTable< TVal, GroupSize >::operator<(), TSparseTable< TVal, GroupSize >::operator=(), TSparseTable< TVal, GroupSize >::operator==(), TSparseTable< THashKeyDat, GroupSize >::Save(), and TSparseTable< TVal, GroupSize >::Swap().
TInt TSparseTable< TVal, GroupSize >::MxVals [private] |
Definition at line 315 of file shash.h.
Referenced by TSparseTable< THashKeyDat, GroupSize >::Load(), TSparseTable< TVal, GroupSize >::operator=(), TSparseTable< TVal, GroupSize >::operator==(), TSparseTable< THashKeyDat, GroupSize >::Reserved(), TSparseTable< THashKeyDat, GroupSize >::Save(), and TSparseTable< TVal, GroupSize >::Swap().
TInt TSparseTable< TVal, GroupSize >::Vals [private] |
Definition at line 315 of file shash.h.
Referenced by TSparseTable< THashKeyDat, GroupSize >::Empty(), TSparseTable< THashKeyDat, GroupSize >::GetDiskSz(), TSparseTable< THashKeyDat, GroupSize >::GetMemUsed(), TSparseTable< THashKeyDat, GroupSize >::Len(), TSparseTable< THashKeyDat, GroupSize >::Load(), TSparseTable< TVal, GroupSize >::operator<(), TSparseTable< TVal, GroupSize >::operator=(), TSparseTable< TVal, GroupSize >::operator==(), TSparseTable< THashKeyDat, GroupSize >::Save(), and TSparseTable< TVal, GroupSize >::Swap().