3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-10-02 05:59:29 +00:00

remove using insert_if_not_there2

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-04-25 15:08:51 -07:00
parent 9ea1cf3c5c
commit a884201d62
47 changed files with 172 additions and 208 deletions

View file

@ -25,11 +25,11 @@ void counter::update(unsigned el, int delta) {
}
int & counter::get(unsigned el) {
return m_data.insert_if_not_there2(el, 0)->get_data().m_value;
return m_data.insert_if_not_there(el, 0);
}
counter & counter::count(unsigned sz, const unsigned * els, int delta) {
for(unsigned i=0; i<sz; i++) {
for(unsigned i = 0; i < sz; i++) {
update(els[i], delta);
}
return *this;
@ -37,32 +37,24 @@ counter & counter::count(unsigned sz, const unsigned * els, int delta) {
unsigned counter::get_positive_count() const {
unsigned cnt = 0;
iterator eit = begin();
iterator eend = end();
for(; eit!=eend; ++eit) {
if( eit->m_value>0 ) {
for (auto const& kv : *this)
if (kv.m_value > 0)
cnt++;
}
}
return cnt;
}
void counter::collect_positive(uint_set & acc) const {
iterator eit = begin();
iterator eend = end();
for(; eit!=eend; ++eit) {
if(eit->m_value>0) { acc.insert(eit->m_key); }
}
for (auto const& kv : *this)
if(kv.m_value > 0)
acc.insert(kv.m_key);
}
bool counter::get_max_positive(unsigned & res) const {
bool found = false;
iterator eit = begin();
iterator eend = end();
for(; eit!=eend; ++eit) {
if( eit->m_value>0 && (!found || eit->m_key>res) ) {
for (auto const& kv : *this) {
if (kv.m_value > 0 && (!found || kv.m_key > res) ) {
found = true;
res = eit->m_key;
res = kv.m_key;
}
}
return found;
@ -76,12 +68,9 @@ unsigned counter::get_max_positive() const {
int counter::get_max_counter_value() const {
int res = 0;
iterator eit = begin();
iterator eend = end();
for (; eit!=eend; ++eit) {
if( eit->m_value>res ) {
res = eit->m_value;
}
for (auto const& kv : *this) {
if (kv.m_value > res)
res = kv.m_value;
}
return res;
}

View file

@ -93,7 +93,7 @@ class ast_counter {
iterator end() const { return m_data.end(); }
int & get(ast * el) {
return m_data.insert_if_not_there2(el, 0)->get_data().m_value;
return m_data.insert_if_not_there(el, 0);
}
void update(ast * el, int delta){
get(el) += delta;

View file

@ -523,10 +523,10 @@ bool bv_bounds::bound_lo(app * v, const numeral& l) {
SASSERT(in_range(v, l));
TRACE("bv_bounds", tout << "lower " << mk_ismt2_pp(v, m_m) << ":" << l << std::endl;);
// l <= v
bound_map::obj_map_entry * const entry = m_unsigned_lowers.insert_if_not_there2(v, l);
if (!(entry->get_data().m_value < l)) return m_okay;
auto& value = m_unsigned_lowers.insert_if_not_there(v, l);
if (!(value < l)) return m_okay;
// improve bound
entry->get_data().m_value = l;
value = l;
return m_okay;
}
@ -534,10 +534,10 @@ bool bv_bounds::bound_up(app * v, const numeral& u) {
SASSERT(in_range(v, u));
TRACE("bv_bounds", tout << "upper " << mk_ismt2_pp(v, m_m) << ":" << u << std::endl;);
// v <= u
bound_map::obj_map_entry * const entry = m_unsigned_uppers.insert_if_not_there2(v, u);
if (!(u < entry->get_data().m_value)) return m_okay;
auto& value = m_unsigned_uppers.insert_if_not_there(v, u);
if (!(u < value)) return m_okay;
// improve bound
entry->get_data().m_value = u;
value = u;
return m_okay;
}

View file

@ -341,11 +341,8 @@ bool factor_rewriter::extract_factors() {
void factor_rewriter::collect_powers() {
m_powers.reset();
for (unsigned i = 0; i < m_factors.size(); ++i) {
obj_map<expr,unsigned>::obj_map_entry* entry = m_powers.insert_if_not_there2(m_factors[i].get(), 0);
if (entry) {
++(entry->get_data().m_value);
}
for (expr* f : m_factors) {
m_powers.insert_if_not_there(f, 0)++;
}
}

View file

@ -1326,7 +1326,7 @@ seq_rewriter::length_comparison seq_rewriter::compare_lengths(unsigned sza, expr
if (m_util.str.is_unit(as[i]))
units_a++;
else
mults.insert_if_not_there2(as[i], 0)->get_data().m_value++;
mults.insert_if_not_there(as[i], 0)++;
}
for (unsigned i = 0; i < szb; ++i) {
if (m_util.str.is_unit(bs[i]))