SNAP Library 6.0, User Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
TB8Set Class Reference

#include <bits.h>

Public Member Functions

 TB8Set ()
 
 TB8Set (const TB8Set &B8Set)
 
 TB8Set (const uchar &_B1)
 
 TB8Set (TSIn &SIn)
 
void Save (TSOut &SOut) const
 
TB8Setoperator= (const TB8Set &BSet)
 
TB8Setoperator= (const uchar &_B1)
 
bool operator== (const TB8Set &BSet) const
 
bool operator< (const TB8Set &BSet) const
 
bool Empty () const
 
TB8SetClr ()
 
TB8SetFill ()
 
bool IsPrefix (const TB8Set &BSet, const int &MnBitN) const
 
uchar GetUCh () 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
 
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
 
TB8Setoperator~ ()
 
TB8Setoperator&= (const TB8Set &BSet)
 
TB8Setoperator|= (const TB8Set &BSet)
 
TB8Setoperator|= (const int &BitN)
 
TB8Setoperator^= (const TB8Set &BSet)
 
TB8Setoperator>>= (const int &ShiftBits)
 
TB8Setoperator<<= (const int &ShiftBits)
 

Private Attributes

TB1Def::TB1 B1
 

Static Private Attributes

static const int Bits =8
 

Friends

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

Detailed Description

Definition at line 166 of file bits.h.

Constructor & Destructor Documentation

TB8Set::TB8Set ( )
inline

Definition at line 171 of file bits.h.

171 : B1(0){}
TB1Def::TB1 B1
Definition: bits.h:169
TB8Set::TB8Set ( const TB8Set B8Set)
inline

Definition at line 172 of file bits.h.

172 : B1(B8Set.B1){}
TB1Def::TB1 B1
Definition: bits.h:169
TB8Set::TB8Set ( const uchar _B1)
inline

Definition at line 173 of file bits.h.

173 : B1(_B1){}
TB1Def::TB1 B1
Definition: bits.h:169
TB8Set::TB8Set ( TSIn SIn)
inline

Definition at line 174 of file bits.h.

174 {SIn.LoadBf(&B1, sizeof(TB1Def::TB1));}
TB1Def::TB1 B1
Definition: bits.h:169
uchar TB1
Definition: bits.h:7
void LoadBf(const void *Bf, const TSize &BfL)
Definition: fl.h:81

Member Function Documentation

TB8Set& TB8Set::Clr ( )
inline

Definition at line 183 of file bits.h.

183 {B1=0; return *this;}
TB1Def::TB1 B1
Definition: bits.h:169
bool TB8Set::Empty ( ) const
inline

Definition at line 182 of file bits.h.

182 {return B1==0;}
TB1Def::TB1 B1
Definition: bits.h:169
void TB8Set::Excl ( const int &  BitN)
inline

Definition at line 193 of file bits.h.

193  {
194  Assert((0<=BitN)&&(BitN<Bits));
195  B1&=TB1Def::TB1(~(TB1Def::B1Def.B1P2T[BitN]));}
static const int Bits
Definition: bits.h:168
TB1Def::TB1 B1
Definition: bits.h:169
#define Assert(Cond)
Definition: bd.h:251
uchar TB1
Definition: bits.h:7
static const TB1Def B1Def
Definition: bits.h:24
TB8Set& TB8Set::Fill ( )
inline

Definition at line 184 of file bits.h.

184 {B1=TB1Def::B1Def.MxB1; return *this;}
TB1Def::TB1 B1
Definition: bits.h:169
static const TB1 MxB1
Definition: bits.h:10
static const TB1Def B1Def
Definition: bits.h:24
int TB8Set::Get0s ( ) const
inline

Definition at line 206 of file bits.h.

206 {return Bits-Get1s();}
static const int Bits
Definition: bits.h:168
int Get1s() const
Definition: bits.h:205
int TB8Set::Get1s ( ) const
inline

Definition at line 205 of file bits.h.

205 {return TB1Def::B1Def.GetB1Bits(B1);}
TB1Def::TB1 B1
Definition: bits.h:169
static int GetB1Bits(const TB1 &B1)
Definition: bits.cpp:18
static const TB1Def B1Def
Definition: bits.h:24
bool TB8Set::GetBit ( const int &  BitN) const
inline

Definition at line 201 of file bits.h.

201  {
202  Assert((0<=BitN)&&(BitN<Bits));
203  return (B1 & TB1Def::B1Def.B1P2T[BitN])!=0;}
static const int Bits
Definition: bits.h:168
TB1Def::TB1 B1
Definition: bits.h:169
#define Assert(Cond)
Definition: bd.h:251
static const TB1Def B1Def
Definition: bits.h:24
int TB8Set::GetBits ( ) const
inline

Definition at line 204 of file bits.h.

204 {return Bits;}
static const int Bits
Definition: bits.h:168
int TB8Set::GetInt ( const int &  MnBitN,
const int &  MxBitN 
) const
inline

Definition at line 214 of file bits.h.

214  {
215  Assert((0<=MnBitN)&&(MnBitN<=MxBitN)&&(MxBitN<Bits));
216  return (B1>>MnBitN) & (TB1Def::B1Def.B1P2T[MxBitN-MnBitN+1]-1);}
static const int Bits
Definition: bits.h:168
TB1Def::TB1 B1
Definition: bits.h:169
TB1 * B1P2T
Definition: bits.h:11
#define Assert(Cond)
Definition: bd.h:251
static const TB1Def B1Def
Definition: bits.h:24
TStr TB8Set::GetStr ( ) const

Definition at line 131 of file bits.cpp.

131  {
132  TChA ChA;
133  for (int BitN=0; BitN<Bits; BitN++){
134  if (In(BitN)){ChA+='1';} else {ChA+='0';}}
135  return ChA;
136 }
static const int Bits
Definition: bits.h:168
bool In(const int &BitN) const
Definition: bits.h:196
Definition: dt.h:201
uchar TB8Set::GetUCh ( ) const
inline

Definition at line 188 of file bits.h.

188 {return B1;}
TB1Def::TB1 B1
Definition: bits.h:169
bool TB8Set::In ( const int &  BitN) const
inline

Definition at line 196 of file bits.h.

196  {
197  Assert((0<=BitN)&&(BitN<Bits));
198  return (B1 & TB1Def::B1Def.B1P2T[BitN])!=0;}
static const int Bits
Definition: bits.h:168
TB1Def::TB1 B1
Definition: bits.h:169
#define Assert(Cond)
Definition: bd.h:251
static const TB1Def B1Def
Definition: bits.h:24
void TB8Set::Incl ( const int &  BitN)
inline

Definition at line 190 of file bits.h.

190  {
191  Assert((0<=BitN)&&(BitN<Bits));
192  B1|=TB1Def::B1Def.B1P2T[BitN];}
static const int Bits
Definition: bits.h:168
TB1Def::TB1 B1
Definition: bits.h:169
TB1 * B1P2T
Definition: bits.h:11
#define Assert(Cond)
Definition: bd.h:251
static const TB1Def B1Def
Definition: bits.h:24
bool TB8Set::IsPrefix ( const TB8Set BSet,
const int &  MnBitN 
) const
inline

Definition at line 185 of file bits.h.

185  {
186  Assert((0<=MnBitN)&&(MnBitN<Bits));
187  return (B1>>MnBitN)==(BSet.B1>>MnBitN);}
static const int Bits
Definition: bits.h:168
TB1Def::TB1 B1
Definition: bits.h:169
#define Assert(Cond)
Definition: bd.h:251
TB8Set& TB8Set::operator&= ( const TB8Set BSet)
inline

Definition at line 219 of file bits.h.

219 {B1&=BSet.B1; return *this;}
TB1Def::TB1 B1
Definition: bits.h:169
bool TB8Set::operator< ( const TB8Set BSet) const
inline

Definition at line 180 of file bits.h.

180 {return B1<BSet.B1;}
TB1Def::TB1 B1
Definition: bits.h:169
TB8Set& TB8Set::operator<<= ( const int &  ShiftBits)
inline

Definition at line 224 of file bits.h.

224 {B1<<=ShiftBits; return *this;}
TB1Def::TB1 B1
Definition: bits.h:169
TB8Set& TB8Set::operator= ( const TB8Set BSet)
inline

Definition at line 177 of file bits.h.

177 {B1=BSet.B1; return *this;}
TB1Def::TB1 B1
Definition: bits.h:169
TB8Set& TB8Set::operator= ( const uchar _B1)
inline

Definition at line 178 of file bits.h.

178 {B1=_B1; return *this;}
TB1Def::TB1 B1
Definition: bits.h:169
bool TB8Set::operator== ( const TB8Set BSet) const
inline

Definition at line 179 of file bits.h.

179 {return B1==BSet.B1;}
TB1Def::TB1 B1
Definition: bits.h:169
TB8Set& TB8Set::operator>>= ( const int &  ShiftBits)
inline

Definition at line 223 of file bits.h.

223 {B1>>=ShiftBits; return *this;}
TB1Def::TB1 B1
Definition: bits.h:169
TB8Set& TB8Set::operator^= ( const TB8Set BSet)
inline

Definition at line 222 of file bits.h.

222 {B1^=BSet.B1; return *this;}
TB1Def::TB1 B1
Definition: bits.h:169
TB8Set& TB8Set::operator|= ( const TB8Set BSet)
inline

Definition at line 220 of file bits.h.

220 {B1|=BSet.B1; return *this;}
TB1Def::TB1 B1
Definition: bits.h:169
TB8Set& TB8Set::operator|= ( const int &  BitN)
inline

Definition at line 221 of file bits.h.

221 {Incl(BitN); return *this;}
void Incl(const int &BitN)
Definition: bits.h:190
TB8Set& TB8Set::operator~ ( )
inline

Definition at line 218 of file bits.h.

218 {B1=TB1Def::TB1(~B1); return *this;}
TB1Def::TB1 B1
Definition: bits.h:169
uchar TB1
Definition: bits.h:7
void TB8Set::PutInt ( const int &  MnBitN,
const int &  MxBitN,
const int &  Val 
)
inline

Definition at line 210 of file bits.h.

210  {
211  Assert((0<=MnBitN)&&(MnBitN<=MxBitN)&&(MxBitN<Bits));
212  B1 &= TB1Def::TB1((~(TB1Def::B1Def.B1P2T[MxBitN-MnBitN+1]-1)) << MnBitN);
213  B1 |= TB1Def::TB1((Val & (TB1Def::B1Def.B1P2T[MxBitN-MnBitN+1]-1)) << MnBitN);}
static const int Bits
Definition: bits.h:168
TB1Def::TB1 B1
Definition: bits.h:169
#define Assert(Cond)
Definition: bd.h:251
uchar TB1
Definition: bits.h:7
static const TB1Def B1Def
Definition: bits.h:24
void TB8Set::Save ( TSOut SOut) const
inline

Definition at line 175 of file bits.h.

175 {SOut.SaveBf(&B1, sizeof(TB1Def::TB1));}
TB1Def::TB1 B1
Definition: bits.h:169
void SaveBf(const void *Bf, const TSize &BfL)
Definition: fl.h:172
uchar TB1
Definition: bits.h:7
void TB8Set::SetBit ( const int &  BitN,
const bool &  Bool 
)
inline

Definition at line 199 of file bits.h.

199  {
200  if (Bool) Incl(BitN); else Excl(BitN);}
void Incl(const int &BitN)
Definition: bits.h:190
void Excl(const int &BitN)
Definition: bits.h:193
void TB8Set::Wr ( )

Definition at line 138 of file bits.cpp.

138  {
139  printf("[");
140  for (int BitN=0; BitN<Bits; BitN++){printf("%d", GetBit(BitN));}
141  printf("]\n");
142 }
static const int Bits
Definition: bits.h:168
bool GetBit(const int &BitN) const
Definition: bits.h:201

Friends And Related Function Documentation

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

Definition at line 228 of file bits.h.

228  {
229  return TB8Set(LBSet)&=RBSet;}
TB8Set()
Definition: bits.h:171
TB8Set operator^ ( const TB8Set LBSet,
const TB8Set RBSet 
)
friend

Definition at line 232 of file bits.h.

232  {
233  return TB8Set(LBSet)^=RBSet;}
TB8Set()
Definition: bits.h:171
TB8Set operator| ( const TB8Set LBSet,
const TB8Set RBSet 
)
friend

Definition at line 230 of file bits.h.

230  {
231  return TB8Set(LBSet)|=RBSet;}
TB8Set()
Definition: bits.h:171
TB8Set operator~ ( const TB8Set BSet)
friend

Definition at line 226 of file bits.h.

226  {
227  return ~TB8Set(BSet);}
Definition: bits.h:166

Member Data Documentation

TB1Def::TB1 TB8Set::B1
private

Definition at line 169 of file bits.h.

const int TB8Set::Bits =8
staticprivate

Definition at line 168 of file bits.h.


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