mirror of
https://github.com/Z3Prover/z3
synced 2025-07-25 21:57:00 +00:00
redo egraph
This commit is contained in:
parent
20be286391
commit
4562c07ceb
11 changed files with 373 additions and 1 deletions
36
src/util/compressed_limit_trail.h
Normal file
36
src/util/compressed_limit_trail.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
|
||||
#include "util/vector.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
class compressed_limit_trail {
|
||||
unsigned_vector m_lim;
|
||||
unsigned m_scopes{ 0 };
|
||||
unsigned m_last{ 0 };
|
||||
public:
|
||||
|
||||
void push(unsigned n) {
|
||||
if (m_last == n)
|
||||
m_scopes++;
|
||||
else {
|
||||
for (; m_scopes > 0; --m_scopes)
|
||||
m_lim.push_back(m_last);
|
||||
m_last = n;
|
||||
}
|
||||
}
|
||||
unsigned pop(unsigned n) {
|
||||
SASSERT(n > 0);
|
||||
SASSERT(m_scopes + m_lim.size() >= n);
|
||||
if (n <= m_scopes) {
|
||||
m_scopes -= n;
|
||||
return m_last;
|
||||
}
|
||||
else {
|
||||
n -= m_scopes;
|
||||
m_scopes = 0;
|
||||
m_last = m_lim[m_lim.size() - n];
|
||||
m_lim.shrink(m_lim.size() - n);
|
||||
return m_last;
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue