SNAP Library 2.1, User Reference
2013-09-25 10:47:25
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <shash.h>
Public Member Functions | |
TSparseGroup () | |
TSparseGroup (TSIn &SIn) | |
TSparseGroup (const TSparseGroup &SG) | |
~TSparseGroup () | |
void | Load (TSIn &SIn) |
void | Save (TSOut &SOut) const |
TSparseGroup & | operator= (const TSparseGroup &SG) |
bool | operator== (const TSparseGroup &SG) const |
bool | operator< (const TSparseGroup &SG) const |
int | Len () const |
int | MxLen () const |
int | Reserved () const |
bool | Empty () const |
void | Clr (const bool &DoDel=true) |
int | GetGroupSize () const |
uint | GetDiskSz () const |
bool | IsEmpty (const int &ValN) const |
const TVal & | Offset (const int &Pos) const |
TVal & | Offset (const int &Pos) |
int | OffsetToPos (int Offset) const |
int | PosToOffset (int Pos) const |
const TVal & | DefVal () const |
const TVal & | Get (const int &ValN) const |
const TVal & | operator[] (const int ValN) const |
TVal & | Set (const int &ValN, const TVal &Val) |
TVal & | Set (const int &ValN) |
void | Del (const int &ValN) |
Private Member Functions | |
bool | BMTest (const int &ValN) const |
void | BMSet (const int &ValN) |
void | BMClear (const int &ValN) |
Static Private Member Functions | |
static int | CharBit (const int &ValN) |
static int | ModBit (const int &ValN) |
static int | PosToOffset (const unsigned char *BitSet, int Pos) |
Private Attributes | |
unsigned char | BitSet [(GroupSize-1)/8+1] |
uint16 | Buckets |
TVal * | Group |
TSparseGroup< TVal, GroupSize >::TSparseGroup | ( | ) | [inline] |
TSparseGroup< TVal, GroupSize >::TSparseGroup | ( | TSIn & | SIn | ) | [inline] |
TSparseGroup< TVal, GroupSize >::TSparseGroup | ( | const TSparseGroup< TVal, GroupSize > & | SG | ) |
TSparseGroup< TVal, GroupSize >::~TSparseGroup | ( | ) | [inline] |
void TSparseGroup< TVal, GroupSize >::BMClear | ( | const int & | ValN | ) | [inline, private] |
void TSparseGroup< TVal, GroupSize >::BMSet | ( | const int & | ValN | ) | [inline, private] |
bool TSparseGroup< TVal, GroupSize >::BMTest | ( | const int & | ValN | ) | const [inline, private] |
static int TSparseGroup< TVal, GroupSize >::CharBit | ( | const int & | ValN | ) | [inline, static, private] |
void TSparseGroup< TVal, GroupSize >::Clr | ( | const bool & | DoDel = true | ) |
const TVal& TSparseGroup< TVal, GroupSize >::DefVal | ( | ) | const [inline] |
void TSparseGroup< TVal, GroupSize >::Del | ( | const int & | ValN | ) |
Definition at line 247 of file shash.h.
{ if (BMTest(ValN)) { const int Offset = PosToOffset(BitSet, ValN); if (--Buckets == 0) { delete [] Group; Group = 0; } else { const TVal *OldGroup = Group; Group = new TVal [Buckets]; for (int b = 0; b < Offset; b++) Group[b] = OldGroup[b]; for (int b = Offset+1; b <= Buckets; b++) Group[b-1] = OldGroup[b]; if (OldGroup != NULL) delete [] OldGroup; } BMClear(ValN); } }
bool TSparseGroup< TVal, GroupSize >::Empty | ( | ) | const [inline] |
const TVal& TSparseGroup< TVal, GroupSize >::Get | ( | const int & | ValN | ) | const [inline] |
uint TSparseGroup< TVal, GroupSize >::GetDiskSz | ( | ) | const [inline] |
int TSparseGroup< TVal, GroupSize >::GetGroupSize | ( | ) | const [inline] |
bool TSparseGroup< TVal, GroupSize >::IsEmpty | ( | const int & | ValN | ) | const [inline] |
int TSparseGroup< TVal, GroupSize >::Len | ( | ) | const [inline] |
void TSparseGroup< TVal, GroupSize >::Load | ( | TSIn & | SIn | ) |
static int TSparseGroup< TVal, GroupSize >::ModBit | ( | const int & | ValN | ) | [inline, static, private] |
int TSparseGroup< TVal, GroupSize >::MxLen | ( | ) | const [inline] |
const TVal& TSparseGroup< TVal, GroupSize >::Offset | ( | const int & | Pos | ) | const [inline] |
TVal& TSparseGroup< TVal, GroupSize >::Offset | ( | const int & | Pos | ) | [inline] |
int TSparseGroup< TVal, GroupSize >::OffsetToPos | ( | int | Offset | ) | const |
bool TSparseGroup< TVal, GroupSize >::operator< | ( | const TSparseGroup< TVal, GroupSize > & | SG | ) | const |
TSparseGroup< TVal, GroupSize > & TSparseGroup< TVal, GroupSize >::operator= | ( | const TSparseGroup< TVal, GroupSize > & | SG | ) |
Definition at line 166 of file shash.h.
{ if (this != &SG) { if (SG.Buckets == 0 && Group != NULL) { delete [] Group; Group = 0; } else { if (Buckets != SG.Buckets) { if (Group != NULL) delete [] Group; Group = new TVal [SG.Buckets]; } for (int b = 0; b < SG.Buckets; b++) { Group[b] = SG.Group[b]; } } Buckets = SG.Buckets; memcpy(BitSet, SG.BitSet, sizeof(BitSet)); } return *this; }
bool TSparseGroup< TVal, GroupSize >::operator== | ( | const TSparseGroup< TVal, GroupSize > & | SG | ) | const |
const TVal& TSparseGroup< TVal, GroupSize >::operator[] | ( | const int | ValN | ) | const [inline] |
int TSparseGroup< TVal, GroupSize >::PosToOffset | ( | const unsigned char * | BitSet, |
int | Pos | ||
) | [static, private] |
Definition at line 113 of file shash.h.
{ static const int bits_in [256] = { // # of bits set in one char 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, }; // [Note: condition pos > 8 is an optimization; convince yourself we // give exactly the same result as if we had pos >= 8 here instead.] int Offset = 0; for ( ; Pos > 8; Pos -= 8 ) // bm[0..pos/8-1] Offset += bits_in[*BitSet++]; // chars we want *all* bits in return Offset + bits_in[*BitSet & ((1 << Pos)-1)]; // the char that includes pos }
int TSparseGroup< TVal, GroupSize >::PosToOffset | ( | int | Pos | ) | const [inline] |
Definition at line 97 of file shash.h.
{ return PosToOffset(BitSet, Pos); }
int TSparseGroup< TVal, GroupSize >::Reserved | ( | ) | const [inline] |
void TSparseGroup< TVal, GroupSize >::Save | ( | TSOut & | SOut | ) | const |
TVal & TSparseGroup< TVal, GroupSize >::Set | ( | const int & | ValN, |
const TVal & | Val | ||
) |
Definition at line 231 of file shash.h.
{ const int Offset = PosToOffset(BitSet, ValN); if (! BMTest(ValN)) { const TVal *OldGroup = Group; Group = new TVal [Buckets+1]; for (int b = 0; b < Offset; b++) Group[b] = OldGroup[b]; for (int b = Offset+1; b <= Buckets; b++) Group[b] = OldGroup[b-1]; if (OldGroup != NULL) delete [] OldGroup; Buckets++; BMSet(ValN); } Group[Offset] = Val; return Group[Offset]; }
TVal& TSparseGroup< TVal, GroupSize >::Set | ( | const int & | ValN | ) | [inline] |
unsigned char TSparseGroup< TVal, GroupSize >::BitSet[(GroupSize-1)/8+1] [private] |
uint16 TSparseGroup< TVal, GroupSize >::Buckets [private] |
TVal* TSparseGroup< TVal, GroupSize >::Group [private] |