32 #ifndef __MEM_RUBY_COMMON_SET_HH__ 33 #define __MEM_RUBY_COMMON_SET_HH__ 48 std::bitset<NUMBER_BITS_PER_SET>
bits;
53 Set(
int size) : m_nSize(size)
55 if (size > NUMBER_BITS_PER_SET)
56 fatal(
"Number of bits(%d) < size specified(%d). " 57 "Increase the number of bits and recompile.\n",
58 NUMBER_BITS_PER_SET, size);
61 Set(
const Set& obj) : m_nSize(obj.m_nSize), bits(obj.bits) {}
103 assert(m_nSize == obj.
m_nSize);
115 for (
int j = m_nSize;
j < NUMBER_BITS_PER_SET; ++
j) {
123 int count()
const {
return bits.count(); }
131 assert(m_nSize == obj.
m_nSize);
132 return bits == obj.
bits;
139 assert(m_nSize == obj.
m_nSize);
149 assert(m_nSize == obj.
m_nSize);
159 std::bitset<NUMBER_BITS_PER_SET>
r = bits & obj.
bits;
170 assert(m_nSize == test.
m_nSize);
171 std::bitset<NUMBER_BITS_PER_SET>
r = bits | test.
bits;
185 return (bits.count() ==
m_nSize);
197 panic(
"No smallest element of an empty set.");
207 if (size > NUMBER_BITS_PER_SET)
208 fatal(
"Number of bits(%d) < size specified(%d). " 209 "Increase the number of bits and recompile.\n",
210 NUMBER_BITS_PER_SET, size);
217 out <<
"[Set (" << m_nSize <<
"): " << bits <<
"]";
229 #endif // __MEM_RUBY_COMMON_SET_HH__ #define panic(...)
This implements a cprintf based panic() function.
bool isSuperset(const Set &test) const
#define fatal(...)
This implements a cprintf based fatal() function.
Set AND(const Set &obj) const
void removeSet(const Set &obj)
bool isEqual(const Set &obj) const
bool isElement(NodeID element) const
std::bitset< NUMBER_BITS_PER_SET > bits
NodeID smallestElement() const
bool isSubset(const Set &test) const
std::ostream & operator<<(std::ostream &out, const Set &obj)
void print(std::ostream &out) const
void addSet(const Set &obj)
Set & operator=(const Set &obj)
bool elementAt(int index) const
bool intersectionIsEmpty(const Set &obj) const
Set OR(const Set &obj) const