mirror of
https://github.com/Z3Prover/z3
synced 2026-03-19 11:33:09 +00:00
updates
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
8a48caf742
commit
27f5541b0b
11 changed files with 2176 additions and 80 deletions
|
|
@ -402,6 +402,27 @@ bool char_set::is_disjoint(char_set const& other) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool char_set::is_subset(char_set const& other) const {
|
||||
// Every range in *this must be fully covered by ranges in other.
|
||||
// Both are sorted, non-overlapping.
|
||||
if (m_ranges.empty())
|
||||
return true;
|
||||
unsigned j = 0;
|
||||
for (unsigned i = 0; i < m_ranges.size(); ++i) {
|
||||
unsigned lo = m_ranges[i].m_lo;
|
||||
unsigned hi = m_ranges[i].m_hi;
|
||||
// Advance j to find covering range in other
|
||||
while (j < other.m_ranges.size() && other.m_ranges[j].m_hi <= lo)
|
||||
++j;
|
||||
if (j >= other.m_ranges.size())
|
||||
return false;
|
||||
// other.m_ranges[j] must fully contain [lo, hi)
|
||||
if (other.m_ranges[j].m_lo > lo || other.m_ranges[j].m_hi < hi)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::ostream& char_set::display(std::ostream& out) const {
|
||||
if (m_ranges.empty()) {
|
||||
out << "{}";
|
||||
|
|
|
|||
|
|
@ -156,6 +156,9 @@ public:
|
|||
// check if two sets are disjoint
|
||||
bool is_disjoint(char_set const& other) const;
|
||||
|
||||
// check if this set is a subset of other (every char in this is also in other)
|
||||
bool is_subset(char_set const& other) const;
|
||||
|
||||
bool operator==(char_set const& other) const { return m_ranges == other.m_ranges; }
|
||||
|
||||
char_set clone() const { char_set r; r.m_ranges = m_ranges; return r; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue