SNAP Library 4.0, User Reference  2017-07-27 13:18:06
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TB32Set Class Reference

#include <bits.h>

Public Member Functions

 TB32Set ()
 
 TB32Set (const TB32Set &B32Set)
 
 TB32Set (const uint &_B4)
 
 TB32Set (TSIn &SIn)
 
void Save (TSOut &SOut) const
 
TB32Setoperator= (const TB32Set &BSet)
 
bool operator== (const TB32Set &BSet) const
 
bool operator< (const TB32Set &BSet) const
 
bool Empty () const
 
TB32SetClr ()
 
TB32SetFill ()
 
bool IsPrefix (const TB32Set &BSet, const int &MnBitN) const
 
uint GetUInt () const
 
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 () const
 
int Get0s () const
 
TStr GetStr () const
 
void Wr ()
 
void PutInt (const int &MnBitN, const int &MxBitN, const int &Val)
 
int GetInt (const int &MnBitN, const int &MxBitN) const
 
TB32Setoperator~ ()
 
TB32Setoperator&= (const TB32Set &BSet)
 
TB32Setoperator|= (const TB32Set &BSet)
 
TB32Setoperator^= (const TB32Set &BSet)
 
TB32Setoperator>>= (const int &ShiftBits)
 
TB32Setoperator<<= (const int &ShiftBits)
 

Private Attributes

TB4Def::TB4 B4
 

Static Private Attributes

static const int Bits =32
 

Friends

TB32Set operator~ (const TB32Set &BSet)
 
TB32Set operator& (const TB32Set &LBSet, const TB32Set &RBSet)
 
TB32Set operator| (const TB32Set &LBSet, const TB32Set &RBSet)
 
TB32Set operator^ (const TB32Set &LBSet, const TB32Set &RBSet)
 

Detailed Description

Definition at line 239 of file bits.h.

Constructor & Destructor Documentation

TB32Set::TB32Set ( )
inline

Definition at line 244 of file bits.h.

244 : B4(0){}
TB4Def::TB4 B4
Definition: bits.h:242
TB32Set::TB32Set ( const TB32Set B32Set)
inline

Definition at line 245 of file bits.h.

245 : B4(B32Set.B4){}
TB4Def::TB4 B4
Definition: bits.h:242
TB32Set::TB32Set ( const uint _B4)
inline

Definition at line 246 of file bits.h.

246 : B4(_B4){}
TB4Def::TB4 B4
Definition: bits.h:242
TB32Set::TB32Set ( TSIn SIn)
inline

Definition at line 247 of file bits.h.

247 {SIn.LoadBf(&B4, sizeof(TB4Def::TB4));}
TB4Def::TB4 B4
Definition: bits.h:242
void LoadBf(const void *Bf, const TSize &BfL)
Definition: fl.h:81
uint TB4
Definition: bits.h:53

Member Function Documentation

TB32Set& TB32Set::Clr ( )
inline

Definition at line 255 of file bits.h.

255 {B4=0; return *this;}
TB4Def::TB4 B4
Definition: bits.h:242
bool TB32Set::Empty ( ) const
inline

Definition at line 254 of file bits.h.

254 {return B4==0;}
TB4Def::TB4 B4
Definition: bits.h:242
void TB32Set::Excl ( const int &  BitN)
inline

Definition at line 265 of file bits.h.

265  {
266  Assert((0<=BitN)&&(BitN<Bits));
267  B4&=~TB4Def::B4Def.B4P2T[BitN];}
TB4Def::TB4 B4
Definition: bits.h:242
static const int Bits
Definition: bits.h:241
#define Assert(Cond)
Definition: bd.h:251
Definition: bits.h:51
TB4 * B4P2T
Definition: bits.h:57
TB32Set& TB32Set::Fill ( )
inline

Definition at line 256 of file bits.h.

256 {B4=TB4Def::B4Def.MxB4; return *this;}
TB4Def::TB4 B4
Definition: bits.h:242
static const TB4 MxB4
Definition: bits.h:56
static const TB4Def B4Def
Definition: bits.h:68
int TB32Set::Get0s ( ) const
inline

Definition at line 280 of file bits.h.

280 {return Bits-Get1s();}
static const int Bits
Definition: bits.h:241
int Get1s() const
Definition: bits.h:279
int TB32Set::Get1s ( ) const
inline

Definition at line 279 of file bits.h.

279 {return TB4Def::B4Def.GetB4Bits(B4);}
TB4Def::TB4 B4
Definition: bits.h:242
static int GetB4Bits(const TB4 &B4)
Definition: bits.cpp:83
static const TB4Def B4Def
Definition: bits.h:68
bool TB32Set::GetBit ( const int &  BitN) const
inline

Definition at line 273 of file bits.h.

273  {
274  Assert((0<=BitN)&&(BitN<Bits));
275  return (B4 & TB4Def::B4Def.B4P2T[BitN])!=0;}
TB4Def::TB4 B4
Definition: bits.h:242
static const int Bits
Definition: bits.h:241
#define Assert(Cond)
Definition: bd.h:251
static const TB4Def B4Def
Definition: bits.h:68
int TB32Set::GetBits ( ) const
inline

Definition at line 278 of file bits.h.

278 {return Bits;}
static const int Bits
Definition: bits.h:241
int TB32Set::GetInt ( const int &  MnBitN,
const int &  MxBitN 
) const
inline

Definition at line 288 of file bits.h.

288  {
289  Assert((0<=MnBitN)&&(MnBitN<=MxBitN)&&(MxBitN<Bits));
290  return (B4>>MnBitN) & (TB4Def::B4Def.B4P2T[MxBitN-MnBitN+1]-1);}
TB4Def::TB4 B4
Definition: bits.h:242
static const int Bits
Definition: bits.h:241
#define Assert(Cond)
Definition: bd.h:251
static const TB4Def B4Def
Definition: bits.h:68
TB4 * B4P2T
Definition: bits.h:57
TStr TB32Set::GetStr ( ) const

Definition at line 148 of file bits.cpp.

148  {
149  TChA ChA;
150  for (int BitN=0; BitN<Bits; BitN++){
151  if (In(BitN)){ChA+='1';} else {ChA+='0';}}
152  return ChA;
153 }
static const int Bits
Definition: bits.h:241
bool In(const int &BitN) const
Definition: bits.h:268
Definition: dt.h:201
uint TB32Set::GetUInt ( ) const
inline

Definition at line 260 of file bits.h.

260 {return B4;}
TB4Def::TB4 B4
Definition: bits.h:242
bool TB32Set::In ( const int &  BitN) const
inline

Definition at line 268 of file bits.h.

268  {
269  Assert((0<=BitN)&&(BitN<Bits));
270  return (B4 & TB4Def::B4Def.B4P2T[BitN])!=0;}
TB4Def::TB4 B4
Definition: bits.h:242
static const int Bits
Definition: bits.h:241
#define Assert(Cond)
Definition: bd.h:251
static const TB4Def B4Def
Definition: bits.h:68
void TB32Set::Incl ( const int &  BitN)
inline

Definition at line 262 of file bits.h.

262  {
263  Assert((0<=BitN)&&(BitN<Bits));
264  B4|=TB4Def::B4Def.B4P2T[BitN];}
TB4Def::TB4 B4
Definition: bits.h:242
static const int Bits
Definition: bits.h:241
#define Assert(Cond)
Definition: bd.h:251
static const TB4Def B4Def
Definition: bits.h:68
TB4 * B4P2T
Definition: bits.h:57
bool TB32Set::IsPrefix ( const TB32Set BSet,
const int &  MnBitN 
) const
inline

Definition at line 257 of file bits.h.

257  {
258  Assert((0<=MnBitN)&&(MnBitN<Bits));
259  return (B4>>MnBitN)==(BSet.B4>>MnBitN);}
TB4Def::TB4 B4
Definition: bits.h:242
static const int Bits
Definition: bits.h:241
#define Assert(Cond)
Definition: bd.h:251
TB32Set& TB32Set::operator&= ( const TB32Set BSet)
inline

Definition at line 293 of file bits.h.

293 {B4&=BSet.B4; return *this;}
TB4Def::TB4 B4
Definition: bits.h:242
bool TB32Set::operator< ( const TB32Set BSet) const
inline

Definition at line 252 of file bits.h.

252 {return B4<BSet.B4;}
TB4Def::TB4 B4
Definition: bits.h:242
TB32Set& TB32Set::operator<<= ( const int &  ShiftBits)
inline

Definition at line 298 of file bits.h.

298 {B4<<=ShiftBits; return *this;}
TB4Def::TB4 B4
Definition: bits.h:242
TB32Set& TB32Set::operator= ( const TB32Set BSet)
inline

Definition at line 250 of file bits.h.

250 {B4=BSet.B4; return *this;}
TB4Def::TB4 B4
Definition: bits.h:242
bool TB32Set::operator== ( const TB32Set BSet) const
inline

Definition at line 251 of file bits.h.

251 {return B4==BSet.B4;}
TB4Def::TB4 B4
Definition: bits.h:242
TB32Set& TB32Set::operator>>= ( const int &  ShiftBits)
inline

Definition at line 297 of file bits.h.

297 {B4>>=ShiftBits; return *this;}
TB4Def::TB4 B4
Definition: bits.h:242
TB32Set& TB32Set::operator^= ( const TB32Set BSet)
inline

Definition at line 296 of file bits.h.

296 {B4^=BSet.B4; return *this;}
TB4Def::TB4 B4
Definition: bits.h:242
TB32Set& TB32Set::operator|= ( const TB32Set BSet)
inline

Definition at line 294 of file bits.h.

294 {B4|=BSet.B4; return *this;}
TB4Def::TB4 B4
Definition: bits.h:242
TB32Set& TB32Set::operator~ ( )
inline

Definition at line 292 of file bits.h.

292 {B4=~B4; return *this;}
TB4Def::TB4 B4
Definition: bits.h:242
void TB32Set::PutInt ( const int &  MnBitN,
const int &  MxBitN,
const int &  Val 
)
inline

Definition at line 284 of file bits.h.

284  {
285  Assert((0<=MnBitN)&&(MnBitN<=MxBitN)&&(MxBitN<Bits));
286  B4 &= (~(TB4Def::B4Def.B4P2T[MxBitN-MnBitN+1]-1)) << MnBitN;
287  B4 |= (Val & (TB4Def::B4Def.B4P2T[MxBitN-MnBitN+1]-1)) << MnBitN;}
TB4Def::TB4 B4
Definition: bits.h:242
static const int Bits
Definition: bits.h:241
#define Assert(Cond)
Definition: bd.h:251
static const TB4Def B4Def
Definition: bits.h:68
TB4 * B4P2T
Definition: bits.h:57
void TB32Set::Save ( TSOut SOut) const
inline

Definition at line 248 of file bits.h.

248 {SOut.SaveBf(&B4, sizeof(TB4Def::TB4));}
TB4Def::TB4 B4
Definition: bits.h:242
void SaveBf(const void *Bf, const TSize &BfL)
Definition: fl.h:172
uint TB4
Definition: bits.h:53
void TB32Set::SetBit ( const int &  BitN,
const bool &  Bool 
)
inline

Definition at line 271 of file bits.h.

271  {
272  if (Bool) Incl(BitN); else Excl(BitN);}
void Incl(const int &BitN)
Definition: bits.h:262
void Excl(const int &BitN)
Definition: bits.h:265
void TB32Set::SwitchBit ( const int &  BitN)
inline

Definition at line 276 of file bits.h.

276  {
277  SetBit(BitN, !GetBit(BitN));}
void SetBit(const int &BitN, const bool &Bool)
Definition: bits.h:271
bool GetBit(const int &BitN) const
Definition: bits.h:273
void TB32Set::Wr ( )

Definition at line 155 of file bits.cpp.

155  {
156  printf("[");
157  for (int BitN=0; BitN<Bits; BitN++){printf("%d", GetBit(BitN));}
158  printf("]\n");
159 }
static const int Bits
Definition: bits.h:241
bool GetBit(const int &BitN) const
Definition: bits.h:273

Friends And Related Function Documentation

TB32Set operator& ( const TB32Set LBSet,
const TB32Set RBSet 
)
friend

Definition at line 302 of file bits.h.

302  {
303  return TB32Set(LBSet)&=RBSet;}
TB32Set()
Definition: bits.h:244
TB32Set operator^ ( const TB32Set LBSet,
const TB32Set RBSet 
)
friend

Definition at line 306 of file bits.h.

306  {
307  return TB32Set(LBSet)^=RBSet;}
TB32Set()
Definition: bits.h:244
TB32Set operator| ( const TB32Set LBSet,
const TB32Set RBSet 
)
friend

Definition at line 304 of file bits.h.

304  {
305  return TB32Set(LBSet)|=RBSet;}
TB32Set()
Definition: bits.h:244
TB32Set operator~ ( const TB32Set BSet)
friend

Definition at line 300 of file bits.h.

300  {
301  return ~TB32Set(BSet);}
Definition: bits.h:239

Member Data Documentation

TB4Def::TB4 TB32Set::B4
private

Definition at line 242 of file bits.h.

const int TB32Set::Bits =32
staticprivate

Definition at line 241 of file bits.h.


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