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
TBSet Class Reference

#include <bits.h>

Collaboration diagram for TBSet:

List of all members.

Public Member Functions

 TBSet ()
 TBSet (const TBSet &BSet)
PBSet Clone () const
 TBSet (const int &_Bits)
 ~TBSet ()
 TBSet (TSIn &SIn)
void Save (TSOut &SOut) const
TBSetoperator= (const TBSet &BSet)
bool operator== (const TBSet &BSet) const
void Gen (const int &_Bits)
void Clr ()
void Fill ()
void Incl (const int &BitN)
void Excl (const int &BitN)
bool In (const int &BitN) const
void SetBit (const int &BitN, const bool &Bool)
bool GetBit (const int &BitN) const
void SwitchBit (const int &BitN)
int GetBits () const
int Get1s ()
int Get0s ()
uint64 GetUInt64 () const
void Wr ()
TBSetoperator~ ()
TBSetoperator&= (const TBSet &BSet)
TBSetoperator|= (const TBSet &BSet)
TBSetoperator|= (const int &BitN)
TBSetoperator^= (const TBSet &BSet)

Static Public Member Functions

static PBSet New (const int &Bits)
static PBSet Load (TSIn &SIn)

Private Member Functions

void SetLastB4 ()

Private Attributes

TCRef CRef
int B4s
int Bits
TB4Def::TB4 LastB4Mask
TB4Def::TB4B4T

Friends

class TPt< TBSet >
TBSet operator~ (const TBSet &BSet)
TBSet operator& (const TBSet &LBSet, const TBSet &RBSet)
TBSet operator| (const TBSet &LBSet, const TBSet &RBSet)
TBSet operator^ (const TBSet &LBSet, const TBSet &RBSet)
TBSet operator& (const TBSet &LBSet, const int &BitN)
TBSet operator| (const TBSet &LBSet, const int &BitN)
TBSet operator^ (const TBSet &LBSet, const int &BitN)

Detailed Description

Definition at line 313 of file bits.h.


Constructor & Destructor Documentation

TBSet::TBSet ( ) [inline]

Definition at line 320 of file bits.h.

: B4s(0), Bits(0), LastB4Mask(0), B4T(NULL){}
TBSet::TBSet ( const TBSet BSet)

Definition at line 163 of file bits.cpp.

References B4s, B4T, Bits, and Gen().

                             :
  B4s(0), Bits(0), LastB4Mask(0), B4T(NULL){
  Gen(BSet.Bits);
  for (int B4N=0; B4N<B4s; B4N++){B4T[B4N]=BSet.B4T[B4N];}
}

Here is the call graph for this function:

TBSet::TBSet ( const int &  _Bits) [inline]

Definition at line 323 of file bits.h.

                         :
    B4s(0), Bits(0), LastB4Mask(0), B4T(NULL){Gen(_Bits);}
TBSet::~TBSet ( ) [inline]

Definition at line 326 of file bits.h.

{delete[] B4T;}
TBSet::TBSet ( TSIn SIn) [inline]

Definition at line 327 of file bits.h.

References TSIn::Load(), TSIn::LoadBf(), and TSIn::LoadNewBf().

                  {
    SIn.Load(B4s); SIn.Load(Bits);
    SIn.LoadBf(&LastB4Mask, sizeof(TB4Def::TB4));
    B4T=(TB4Def::TB4*)SIn.LoadNewBf(B4s*sizeof(TB4Def::TB4));}

Here is the call graph for this function:


Member Function Documentation

PBSet TBSet::Clone ( ) const [inline]

Definition at line 322 of file bits.h.

{return PBSet(new TBSet(*this));}
void TBSet::Clr ( )

Definition at line 192 of file bits.cpp.

References B4s, and B4T.

Referenced by Gen().

               {
  for (int B4N=0; B4N<B4s; B4N++){B4T[B4N]=0;}}

Here is the caller graph for this function:

void TBSet::Excl ( const int &  BitN) [inline]

Definition at line 348 of file bits.h.

References Assert, TB4Def::B4Bits, TB4Def::B4Def, and TB4Def::B4P2T.

                            {
    Assert((0<=BitN)&&(BitN<Bits));
    B4T[BitN/TB4Def::B4Def.B4Bits]&=
     ~TB4Def::B4Def.B4P2T[BitN%TB4Def::B4Def.B4Bits];}
void TBSet::Fill ( )

Definition at line 195 of file bits.cpp.

References B4s, B4T, and TB4Def::MxB4.

                {
  for (int B4N=0; B4N<B4s; B4N++){B4T[B4N]=TB4Def::B4Def.MxB4;}}
void TBSet::Gen ( const int &  _Bits)

Definition at line 182 of file bits.cpp.

References TB4Def::B4Bits, TB4Def::B4P2T, B4s, B4T, Bits, Clr(), LastB4Mask, and TB4Def::MxB4.

Referenced by operator=(), TBSet(), and TXmlChDef::TXmlChDef().

                               {
  if (B4T!=NULL){delete[] B4T;}
  Bits=_Bits;
  B4T=new TB4Def::TB4[B4s=(Bits-1)/TB4Def::B4Def.B4Bits+1];
  LastB4Mask=TB4Def::B4Def.MxB4;
  for (int BitN=Bits; BitN<B4s*TB4Def::B4Def.B4Bits; BitN++){
    LastB4Mask&= ~TB4Def::B4Def.B4P2T[BitN%TB4Def::B4Def.B4Bits];}
  Clr();
}

Here is the call graph for this function:

Here is the caller graph for this function:

int TBSet::Get0s ( ) [inline]

Definition at line 366 of file bits.h.

{return Bits-Get1s();}
int TBSet::Get1s ( )

Definition at line 198 of file bits.cpp.

References B4s, B4T, TB4Def::GetB4Bits(), and SetLastB4().

                {
  int Ones=0; SetLastB4();
  for (int B4N=0; B4N<B4s; B4N++){Ones += TB4Def::B4Def.GetB4Bits(B4T[B4N]);}
  return Ones;
}

Here is the call graph for this function:

bool TBSet::GetBit ( const int &  BitN) const [inline]

Definition at line 358 of file bits.h.

References Assert, and TB4Def::B4Def.

Referenced by Wr().

                                     {
    Assert((0<=BitN)&&(BitN<Bits));
    return (B4T[BitN/TB4Def::B4Def.B4Bits] &
     TB4Def::B4Def.B4P2T[BitN%TB4Def::B4Def.B4Bits])!=0;}

Here is the caller graph for this function:

int TBSet::GetBits ( ) const [inline]

Definition at line 364 of file bits.h.

{return Bits;}
uint64 TBSet::GetUInt64 ( ) const [inline]

Definition at line 367 of file bits.h.

References Assert.

                           {
    Assert(Bits>=64); uint64 Val; memcpy(&Val, B4T, 8); return Val;}
bool TBSet::In ( const int &  BitN) const [inline]

Definition at line 352 of file bits.h.

References Assert, and TB4Def::B4Def.

                                 {
    Assert((0<=BitN)&&(BitN<Bits));
    return (B4T[BitN/TB4Def::B4Def.B4Bits] &
     TB4Def::B4Def.B4P2T[BitN%TB4Def::B4Def.B4Bits])!=0;}
void TBSet::Incl ( const int &  BitN) [inline]

Definition at line 344 of file bits.h.

References Assert, TB4Def::B4Bits, TB4Def::B4Def, and TB4Def::B4P2T.

Referenced by TXmlChDef::SetChTy().

                            {
    Assert((0<=BitN)&&(BitN<Bits));
    B4T[BitN/TB4Def::B4Def.B4Bits]|=
     TB4Def::B4Def.B4P2T[BitN%TB4Def::B4Def.B4Bits];}

Here is the caller graph for this function:

static PBSet TBSet::Load ( TSIn SIn) [inline, static]

Definition at line 331 of file bits.h.

{return new TBSet(SIn);}
static PBSet TBSet::New ( const int &  Bits) [inline, static]

Definition at line 325 of file bits.h.

{return PBSet(new TBSet(Bits));}
TBSet& TBSet::operator&= ( const TBSet BSet) [inline]

Definition at line 373 of file bits.h.

References Assert, B4s, and B4T.

                                      {
    Assert(B4s==BSet.B4s);
    for (int B4N=0; B4N<B4s; B4N++){B4T[B4N]&=BSet.B4T[B4N];} return *this;}
TBSet & TBSet::operator= ( const TBSet BSet)

Definition at line 169 of file bits.cpp.

References B4s, B4T, Bits, and Gen().

                                        {
  if (this!=&BSet){
    if (Bits!=BSet.Bits){Gen(BSet.Bits);}
    for (int B4N=0; B4N<B4s; B4N++){B4T[B4N]=BSet.B4T[B4N];}}
  return *this;
}

Here is the call graph for this function:

bool TBSet::operator== ( const TBSet BSet) const

Definition at line 176 of file bits.cpp.

References B4s, B4T, Bits, and LastB4Mask.

                                              {
  if (Bits!=BSet.Bits){return false;}
  for (int B4N=0; B4N<B4s-1; B4N++){if (B4T[B4N]!=BSet.B4T[B4N]){return false;}}
  return (B4s>0)&&((B4T[B4s-1]&LastB4Mask)==(BSet.B4T[B4s-1]&BSet.LastB4Mask));
}
TBSet& TBSet::operator^= ( const TBSet BSet) [inline]

Definition at line 381 of file bits.h.

References Assert, B4s, and B4T.

                                      {
    Assert(B4s==BSet.B4s);
    for (int B4N=0; B4N<B4s; B4N++){B4T[B4N]^=BSet.B4T[B4N];} return *this;}
TBSet& TBSet::operator|= ( const TBSet BSet) [inline]

Definition at line 376 of file bits.h.

References Assert, B4s, and B4T.

                                      {
    Assert(B4s==BSet.B4s);
    for (int B4N=0; B4N<B4s; B4N++){B4T[B4N]|=BSet.B4T[B4N];} return *this;}
TBSet& TBSet::operator|= ( const int &  BitN) [inline]

Definition at line 379 of file bits.h.

                                    {
    Incl(BitN); return *this;}
TBSet& TBSet::operator~ ( ) [inline]

Definition at line 371 of file bits.h.

                    {
    for (int B4N=0; B4N<B4s; B4N++){B4T[B4N]=~B4T[B4N];} return *this;}
void TBSet::Save ( TSOut SOut) const [inline]

Definition at line 332 of file bits.h.

References TSOut::Save(), and TSOut::SaveBf().

                               {
    SOut.Save(B4s); SOut.Save(Bits);
    SOut.SaveBf(&LastB4Mask, sizeof(TB4Def::TB4));
    SOut.SaveBf(B4T, B4s*sizeof(TB4Def::TB4));}

Here is the call graph for this function:

void TBSet::SetBit ( const int &  BitN,
const bool &  Bool 
) [inline]

Definition at line 356 of file bits.h.

                                                {
    if (Bool){Incl(BitN);} else {Excl(BitN);}}
void TBSet::SetLastB4 ( ) [inline, private]

Definition at line 318 of file bits.h.

Referenced by Get1s().

Here is the caller graph for this function:

void TBSet::SwitchBit ( const int &  BitN) [inline]

Definition at line 362 of file bits.h.

                                 {
    SetBit(BitN, !GetBit(BitN));}
void TBSet::Wr ( )

Definition at line 204 of file bits.cpp.

References Bits, and GetBit().

              {
  for (int BitN=0; BitN<Bits; BitN++){printf("%d", GetBit(BitN));}
  //printf("\n");
}

Here is the call graph for this function:


Friends And Related Function Documentation

TBSet operator& ( const TBSet LBSet,
const TBSet RBSet 
) [friend]

Definition at line 387 of file bits.h.

                                                                {
    return TBSet(LBSet)&=RBSet;}
TBSet operator& ( const TBSet LBSet,
const int &  BitN 
) [friend]

Definition at line 394 of file bits.h.

                                                             {
    return TBSet(LBSet)&=BitN;}
TBSet operator^ ( const TBSet LBSet,
const TBSet RBSet 
) [friend]

Definition at line 391 of file bits.h.

                                                                {
    return TBSet(LBSet)^=RBSet;}
TBSet operator^ ( const TBSet LBSet,
const int &  BitN 
) [friend]

Definition at line 398 of file bits.h.

                                                             {
    return TBSet(LBSet)^=BitN;}
TBSet operator| ( const TBSet LBSet,
const TBSet RBSet 
) [friend]

Definition at line 389 of file bits.h.

                                                                {
    return TBSet(LBSet)|=RBSet;}
TBSet operator| ( const TBSet LBSet,
const int &  BitN 
) [friend]

Definition at line 396 of file bits.h.

                                                             {
    return TBSet(LBSet)|=BitN;}
TBSet operator~ ( const TBSet BSet) [friend]

Definition at line 385 of file bits.h.

                                           {
    return ~TBSet(BSet);}
friend class TPt< TBSet > [friend]

Definition at line 313 of file bits.h.


Member Data Documentation

int TBSet::B4s [private]

Definition at line 315 of file bits.h.

Referenced by Clr(), Fill(), Gen(), Get1s(), operator&=(), operator=(), operator==(), operator^=(), operator|=(), and TBSet().

TB4Def::TB4* TBSet::B4T [private]

Definition at line 317 of file bits.h.

Referenced by Clr(), Fill(), Gen(), Get1s(), operator&=(), operator=(), operator==(), operator^=(), operator|=(), and TBSet().

int TBSet::Bits [private]

Definition at line 315 of file bits.h.

Referenced by Gen(), operator=(), operator==(), TBSet(), and Wr().

TCRef TBSet::CRef [private]

Definition at line 313 of file bits.h.

Definition at line 316 of file bits.h.

Referenced by Gen(), and operator==().


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