COPASI API  4.16.103
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
CZeroSet Class Reference

#include <CZeroSet.h>

Collaboration diagram for CZeroSet:
Collaboration graph
[legend]

Classes

class  CIndex
 

Public Member Functions

 CZeroSet (const size_t &index=0)
 
 CZeroSet (const CZeroSet &src)
 
size_t getNumberOfBits () const
 
const size_t & getNumberOfSetBits () const
 
size_t getNumberOfUnsetBits () const
 
bool isExtremeRay (const std::vector< CStepMatrixColumn * > &columns) const
 
bool isSet (const CIndex &index) const
 
CZeroSetoperator&= (const CZeroSet &rhs)
 
bool operator== (const CZeroSet &rhs) const
 
bool operator>= (const CZeroSet &rhs) const
 
CZeroSetoperator|= (const CZeroSet &rhs)
 
void setBit (const CIndex &index)
 
void unsetBit (const CIndex &index)
 
 ~CZeroSet ()
 

Static Public Member Functions

static CZeroSet intersection (const CZeroSet &set1, const CZeroSet &set2)
 

Private Member Functions

size_t countSetBits (size_t bits)
 

Private Attributes

CVector< size_t > mBitSet
 
size_t mIgnoredBits
 
size_t mNumberSetBits
 

Friends

std::ostream & operator<< (std::ostream &, const CZeroSet &)
 

Detailed Description

Definition at line 30 of file CZeroSet.h.

Constructor & Destructor Documentation

CZeroSet::CZeroSet ( const size_t &  index = 0)

Definition at line 80 of file CZeroSet.cpp.

References C_INVALID_INDEX, and mBitSet.

80  :
81  mBitSet(size / (CHAR_BIT * sizeof(size_t)) + 1),
82  mIgnoredBits(mBitSet.size() * CHAR_BIT * sizeof(size_t) - size),
83  mNumberSetBits(size)
84 {
86 }
#define C_INVALID_INDEX
Definition: copasi.h:222
size_t mIgnoredBits
Definition: CZeroSet.h:174
size_t mNumberSetBits
Definition: CZeroSet.h:176
size_t size() const
Definition: CVector.h:100
CVector< size_t > mBitSet
Definition: CZeroSet.h:172
CZeroSet::CZeroSet ( const CZeroSet src)

Definition at line 88 of file CZeroSet.cpp.

88  :
89  mBitSet(src.mBitSet),
92 {}
size_t mIgnoredBits
Definition: CZeroSet.h:174
size_t mNumberSetBits
Definition: CZeroSet.h:176
CVector< size_t > mBitSet
Definition: CZeroSet.h:172
CZeroSet::~CZeroSet ( )

Definition at line 94 of file CZeroSet.cpp.

95 {}

Member Function Documentation

size_t CZeroSet::countSetBits ( size_t  bits)
inlineprivate

Definition at line 178 of file CZeroSet.h.

Referenced by operator&=(), and operator|=().

179  {
180  size_t numberOfBits = 0;
181 
182  for (size_t i = 0; i < CHAR_BIT * sizeof(size_t); ++i)
183  {
184  if ((bits >> i) & 1)
185  {
186  numberOfBits++;
187  }
188  }
189 
190  return numberOfBits;
191  }
size_t CZeroSet::getNumberOfBits ( ) const
inline

Definition at line 95 of file CZeroSet.h.

References mBitSet, mIgnoredBits, and CVectorCore< CType >::size().

Referenced by CStepMatrixColumn::getAllUnsetBitIndexes(), and operator<<().

96  {
97  return mBitSet.size() * CHAR_BIT * sizeof(size_t) - mIgnoredBits;
98  }
size_t mIgnoredBits
Definition: CZeroSet.h:174
size_t size() const
Definition: CVector.h:100
CVector< size_t > mBitSet
Definition: CZeroSet.h:172
const size_t& CZeroSet::getNumberOfSetBits ( ) const
inline

Definition at line 85 of file CZeroSet.h.

References mNumberSetBits.

Referenced by CBitPatternTreeMethod::combine(), and CBitPatternMethod::combine().

86  {
87  return mNumberSetBits;
88  }
size_t mNumberSetBits
Definition: CZeroSet.h:176
size_t CZeroSet::getNumberOfUnsetBits ( ) const
inline

Definition at line 90 of file CZeroSet.h.

References mBitSet, mIgnoredBits, mNumberSetBits, and CVectorCore< CType >::size().

Referenced by CStepMatrix::getUnsetBitIndexes().

91  {
92  return mBitSet.size() * CHAR_BIT * sizeof(size_t) - mIgnoredBits - mNumberSetBits;
93  }
size_t mIgnoredBits
Definition: CZeroSet.h:174
size_t mNumberSetBits
Definition: CZeroSet.h:176
size_t size() const
Definition: CVector.h:100
CVector< size_t > mBitSet
Definition: CZeroSet.h:172
static CZeroSet CZeroSet::intersection ( const CZeroSet set1,
const CZeroSet set2 
)
inlinestatic

Definition at line 137 of file CZeroSet.h.

Referenced by CBitPatternTreeMethod::combine(), and CBitPatternMethod::combine().

138  {
139  CZeroSet Intersection(set1);
140  return Intersection &= set2;
141  }
bool CZeroSet::isExtremeRay ( const std::vector< CStepMatrixColumn * > &  columns) const

Definition at line 97 of file CZeroSet.cpp.

Referenced by CBitPatternTreeMethod::combine(), and CBitPatternMethod::combine().

98 {
99  std::vector< CStepMatrixColumn * >::const_iterator it = columns.begin();
100  std::vector< CStepMatrixColumn * >::const_iterator end = columns.end();
101 
102  for (; it != end; ++it)
103  {
104  if (*it != NULL &&
105  (*it)->getZeroSet() >= *this)
106  {
107  return false;
108  }
109  }
110 
111  return true;
112 }
bool CZeroSet::isSet ( const CIndex index) const
inline

Definition at line 80 of file CZeroSet.h.

References CZeroSet::CIndex::mBit, mBitSet, and CZeroSet::CIndex::mIndex.

Referenced by CStepMatrixColumn::getAllUnsetBitIndexes(), CStepMatrix::getUnsetBitIndexes(), and operator<<().

81  {
82  return (mBitSet[index.mIndex] & index.mBit) > 0;
83  }
CVector< size_t > mBitSet
Definition: CZeroSet.h:172
CZeroSet& CZeroSet::operator&= ( const CZeroSet rhs)
inline

Definition at line 118 of file CZeroSet.h.

References CVectorCore< CType >::array(), countSetBits(), mBitSet, mIgnoredBits, mNumberSetBits, and CVectorCore< CType >::size().

119  {
120  size_t * pIt = mBitSet.array();
121  size_t * pEnd = pIt + mBitSet.size();
122  const size_t * pRhs = rhs.mBitSet.array();
123  mNumberSetBits = 0;
124 
125  for (; pIt != pEnd; ++pIt, ++pRhs)
126  {
127  *pIt &= *pRhs;
128  mNumberSetBits += countSetBits(*pIt);
129  }
130 
132 
133  return *this;
134  }
size_t countSetBits(size_t bits)
Definition: CZeroSet.h:178
size_t mIgnoredBits
Definition: CZeroSet.h:174
size_t mNumberSetBits
Definition: CZeroSet.h:176
size_t size() const
Definition: CVector.h:100
CType * array()
Definition: CVector.h:139
CVector< size_t > mBitSet
Definition: CZeroSet.h:172
bool CZeroSet::operator== ( const CZeroSet rhs) const
inline

Definition at line 159 of file CZeroSet.h.

References CVectorCore< CType >::array(), mBitSet, mNumberSetBits, and CVectorCore< CType >::size().

160  {
161  if (mNumberSetBits != rhs.mNumberSetBits)
162  return false;
163 
164  return memcmp(mBitSet.array(), rhs.mBitSet.array(),
165  mBitSet.size() * sizeof(size_t)) == 0;
166  }
size_t mNumberSetBits
Definition: CZeroSet.h:176
size_t size() const
Definition: CVector.h:100
CType * array()
Definition: CVector.h:139
CVector< size_t > mBitSet
Definition: CZeroSet.h:172
bool CZeroSet::operator>= ( const CZeroSet rhs) const
inline

Definition at line 144 of file CZeroSet.h.

References CVectorCore< CType >::array(), mBitSet, and CVectorCore< CType >::size().

145  {
146  const size_t * pIt = mBitSet.array();
147  const size_t * pEnd = pIt + mBitSet.size();
148  const size_t * pRhs = rhs.mBitSet.array();
149 
150  for (; pIt != pEnd; ++pIt, ++pRhs)
151  {
152  if (*pIt != (*pIt | *pRhs))
153  return false;
154  }
155 
156  return true;
157  }
size_t size() const
Definition: CVector.h:100
CType * array()
Definition: CVector.h:139
CVector< size_t > mBitSet
Definition: CZeroSet.h:172
CZeroSet& CZeroSet::operator|= ( const CZeroSet rhs)
inline

Definition at line 100 of file CZeroSet.h.

References CVectorCore< CType >::array(), countSetBits(), mBitSet, mIgnoredBits, mNumberSetBits, and CVectorCore< CType >::size().

101  {
102  size_t * pIt = mBitSet.array();
103  size_t * pEnd = pIt + mBitSet.size();
104  const size_t * pRhs = rhs.mBitSet.array();
105  mNumberSetBits = 0;
106 
107  for (; pIt != pEnd; ++pIt, ++pRhs)
108  {
109  *pIt |= *pRhs;
110  mNumberSetBits += countSetBits(*pIt);
111  }
112 
114 
115  return *this;
116  }
size_t countSetBits(size_t bits)
Definition: CZeroSet.h:178
size_t mIgnoredBits
Definition: CZeroSet.h:174
size_t mNumberSetBits
Definition: CZeroSet.h:176
size_t size() const
Definition: CVector.h:100
CType * array()
Definition: CVector.h:139
CVector< size_t > mBitSet
Definition: CZeroSet.h:172
void CZeroSet::setBit ( const CIndex index)
inline

Definition at line 68 of file CZeroSet.h.

References CZeroSet::CIndex::mBit, mBitSet, CZeroSet::CIndex::mIndex, and mNumberSetBits.

69  {
70  mBitSet[index.mIndex] |= index.mBit;
72  }
size_t mNumberSetBits
Definition: CZeroSet.h:176
CVector< size_t > mBitSet
Definition: CZeroSet.h:172
void CZeroSet::unsetBit ( const CIndex index)
inline

Definition at line 74 of file CZeroSet.h.

References mBitSet, CZeroSet::CIndex::mIndex, CZeroSet::CIndex::mNotBit, and mNumberSetBits.

Referenced by CStepMatrixColumn::unsetBit().

75  {
76  mBitSet[index.mIndex] &= index.mNotBit;
78  }
size_t mNumberSetBits
Definition: CZeroSet.h:176
CVector< size_t > mBitSet
Definition: CZeroSet.h:172

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const CZeroSet set 
)
friend

Definition at line 114 of file CZeroSet.cpp.

115 {
116  const size_t * pIt = set.mBitSet.array();
117  const size_t * pEnd = pIt + set.mBitSet.size();
118 
119  size_t CurrentBit = 0;
120  size_t LastBit = set.mBitSet.size() * CHAR_BIT * sizeof(size_t) - set.mIgnoredBits;
121 
122  os << ' ';
123 
124  for (; pIt != pEnd; ++pIt)
125  {
126  for (size_t i = 0;
127  i < CHAR_BIT * sizeof(size_t) && CurrentBit < LastBit;
128  ++i, ++CurrentBit)
129  {
130  if ((*pIt >> i) & 1)
131  {
132  os << 1;
133  }
134  else
135  {
136  os << 0;
137  }
138  }
139 
140  os << ' ';
141  }
142 
143  os << " " << set.mNumberSetBits << std::endl;
144 
145  return os;
146 }
size_t mIgnoredBits
Definition: CZeroSet.h:174
size_t mNumberSetBits
Definition: CZeroSet.h:176
size_t size() const
Definition: CVector.h:100
CType * array()
Definition: CVector.h:139
CVector< size_t > mBitSet
Definition: CZeroSet.h:172

Member Data Documentation

CVector<size_t> CZeroSet::mBitSet
private
size_t CZeroSet::mIgnoredBits
private

Definition at line 174 of file CZeroSet.h.

Referenced by getNumberOfBits(), getNumberOfUnsetBits(), operator&=(), operator<<(), and operator|=().

size_t CZeroSet::mNumberSetBits
private

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