3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-08 18:31:49 +00:00
z3/lib/approx_set.cpp
Leonardo de Moura e9eab22e5c Z3 sources
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2012-10-02 11:35:25 -07:00

53 lines
887 B
C++

/*++
Copyright (c) 2006 Microsoft Corporation
Module Name:
approx_set.cpp
Abstract:
Approximated sets.
Author:
Leonardo de Moura (leonardo) 2007-03-02.
Revision History:
--*/
#include"approx_set.h"
void approx_set::display(std::ostream & out) const {
out << "{";
bool first = true;
unsigned long long s = m_set;
for (unsigned i = 0; i < approx_set_traits<unsigned long long>::capacity; i++) {
if ((s & 1) != 0) {
if (first) {
first = false;
}
else {
out << ", ";
}
out << i;
}
s = s >> 1;
}
out << "}";
}
unsigned approx_set::size() const {
unsigned long long tmp = m_set;
unsigned r = 0;
while (tmp > 0) {
if ((tmp & 1) != 0) {
r++;
}
tmp = tmp >> 1;
}
return r;
}