3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-05 09:04:07 +00:00

Prefer using empty rather than size comparisons.

This commit is contained in:
Bruce Mitchener 2018-11-27 21:42:04 +07:00
parent a83097d5cc
commit e570940662
56 changed files with 104 additions and 104 deletions

View file

@ -472,7 +472,7 @@ extern "C" {
model_smt2_pp(buffer, mk_c(c)->m(), *(to_model_ref(m)), 0);
// Hack for removing the trailing '\n'
result = buffer.str();
if (result.size() != 0)
if (!result.empty())
result.resize(result.size()-1);
}
else {

View file

@ -399,12 +399,12 @@ class smt_printer {
pp_marked_expr(n->get_arg(0));
m_out << ") (_ bv1 1))";
}
else if (m_manager.is_label(n, pos, names) && names.size() >= 1) {
else if (m_manager.is_label(n, pos, names) && !names.empty()) {
m_out << "(! ";
pp_marked_expr(n->get_arg(0));
m_out << (pos?":lblpos":":lblneg") << " " << m_renaming.get_symbol(names[0], false) << ")";
}
else if (m_manager.is_label_lit(n, names) && names.size() >= 1) {
else if (m_manager.is_label_lit(n, names) && !names.empty()) {
m_out << "(! true :lblpos " << m_renaming.get_symbol(names[0], false) << ")";
}
else if (num_args == 0) {
@ -952,7 +952,7 @@ void ast_smt_pp::display_smt2(std::ostream& strm, expr* n) {
if (m_logic != symbol::null && m_logic != symbol("")) {
strm << "(set-logic " << m_logic << ")\n";
}
if (m_attributes.size() > 0) {
if (!m_attributes.empty()) {
strm << "; " << m_attributes.c_str();
}

View file

@ -436,7 +436,7 @@ struct expr2polynomial::imp {
margs.push_back(t);
}
}
if (margs.size() == 0) {
if (margs.empty()) {
args.push_back(m_autil.mk_numeral(rational(1), is_int));
}
else if (margs.size() == 1) {
@ -447,7 +447,7 @@ struct expr2polynomial::imp {
}
}
if (args.size() == 0) {
if (args.empty()) {
r = m_autil.mk_numeral(rational(0), is_int);
}
else if (args.size() == 1) {

View file

@ -238,7 +238,7 @@ class reduce_hypotheses {
{ args.push_back(fact); }
if (args.size() == 0) { return pf; }
if (args.empty()) { return pf; }
else if (args.size() == 1) {
lemma = args.get(0);
} else {

View file

@ -137,7 +137,7 @@ ATOMIC_CMD(get_assignment_cmd, "get-assignment", "retrieve assignment", {
symbol const & name = kv.m_key;
macro_decls const & _m = kv.m_value;
for (auto md : _m) {
if (md.m_domain.size() == 0 && ctx.m().is_bool(md.m_body)) {
if (md.m_domain.empty() && ctx.m().is_bool(md.m_body)) {
model::scoped_model_completion _scm(*m, true);
expr_ref val = (*m)(md.m_body);
if (ctx.m().is_true(val) || ctx.m().is_false(val)) {

View file

@ -2108,7 +2108,7 @@ void cmd_context::dt_eh::operator()(sort * dt, pdecl* pd) {
m_owner.insert(a);
}
}
if (m_owner.m_scopes.size() > 0) {
if (!m_owner.m_scopes.empty()) {
m_owner.pm().inc_ref(pd);
m_owner.m_psort_inst_stack.push_back(pd);
}

View file

@ -224,7 +224,7 @@ public:
ctx.display_sat_result(r);
result->set_status(r);
if (r == l_undef) {
if (reason_unknown != "") {
if (!reason_unknown.empty()) {
result->m_unknown = reason_unknown;
// ctx.diagnostic_stream() << "\"" << escaped(reason_unknown.c_str(), true) << "\"" << std::endl;
}

View file

@ -67,7 +67,7 @@ namespace polynomial {
bool first = true;
out << "[";
for (unsigned i = 0; i < m_var2degree.size(); ++ i) {
if (m_var2degree.size() > 0) {
if (!m_var2degree.empty()) {
if (!first) {
out << ",";
}

View file

@ -96,7 +96,7 @@ namespace upolynomial {
void core_manager::factors::display(std::ostream & out) const {
out << nm().to_string(m_constant);
if (m_factors.size() > 0) {
if (!m_factors.empty()) {
for (unsigned i = 0; i < m_factors.size(); ++ i) {
out << " * (";
m_upm.display(out, m_factors[i]);

View file

@ -532,7 +532,7 @@ bool check_hansel_lift(z_manager & upm, numeral_vector const & C,
upm.mul(A_lifted.size(), A_lifted.c_ptr(), B_lifted.size(), B_lifted.c_ptr(), test1);
upm.sub(C.size(), C.c_ptr(), test1.size(), test1.c_ptr(), test1);
to_zp_manager(br_upm, test1);
if (test1.size() != 0) {
if (!test1.empty()) {
TRACE("polynomial::factorization::bughunt",
tout << "sage: R.<x> = ZZ['x']" << endl;
tout << "sage: A = "; upm.display(tout, A); tout << endl;

View file

@ -401,7 +401,7 @@ namespace upolynomial {
} else {
if (selection_i >= m_current.size() || (int) current < m_current[selection_i]) {
SASSERT(m_factors.get_degree(current) == 1);
if (out.size() == 0) {
if (out.empty()) {
upm.set(m_factors[current].size(), m_factors[current].c_ptr(), out);
} else {
upm.mul(out.size(), out.c_ptr(), m_factors[current].size(), m_factors[current].c_ptr(), out);

View file

@ -3466,11 +3466,11 @@ namespace realclosure {
// ---------------------------------
bool is_monic(value_ref_buffer const & p) {
return p.size() > 0 && is_rational_one(p[p.size() - 1]);
return !p.empty() && is_rational_one(p[p.size() - 1]);
}
bool is_monic(polynomial const & p) {
return p.size() > 0 && is_rational_one(p[p.size() - 1]);
return !p.empty() && is_rational_one(p[p.size() - 1]);
}
/**

View file

@ -85,7 +85,7 @@ struct model::value_proc : public some_value_proc {
expr * operator()(sort * s) override {
ptr_vector<expr> * u = nullptr;
if (m_model.m_usort2universe.find(s, u)) {
if (u->size() > 0)
if (!u->empty())
return u->get(0);
}
return nullptr;

View file

@ -230,7 +230,7 @@ namespace datalog {
bool is_closed() const { return m_stratifier != 0; }
unsigned get_num_rules() const { return m_rules.size(); }
bool empty() const { return m_rules.size() == 0; }
bool empty() const { return m_rules.empty(); }
rule * get_rule(unsigned i) const { return m_rules[i]; }
rule * last() const { return m_rules[m_rules.size()-1]; }

View file

@ -986,7 +986,7 @@ namespace datalog {
m_sort2pred.insert(new_sorts[i].get(), it->m_key);
m_pinned.push_back(new_sorts[i].get());
}
if (new_sorts.size() > 0) {
if (!new_sorts.empty()) {
TRACE("bmc", dtu.display_datatype(new_sorts[0].get(), tout););
}
del_datatype_decls(dts.size(), dts.c_ptr());

View file

@ -1057,7 +1057,7 @@ protected:
line.push_back(ch);
ch = strm.get();
}
return line.size() > 0;
return !line.empty();
}
void add_rule(app* head, unsigned sz, app* const* body, const bool * is_neg) {

View file

@ -487,7 +487,7 @@ namespace datalog {
res->init(*res_table, joined_orelations, true);
if(m_tr_table_joined_cols.size()) {
if(!m_tr_table_joined_cols.empty()) {
//There were some shared variables between the table and the relation part.
//We enforce those equalities here.
if(!m_filter_tr_identities) {

View file

@ -170,7 +170,7 @@ namespace datalog {
SASSERT(is_inner_col(idx));
return m_sig2inner[idx];
}
bool no_sieved_columns() const { return m_ignored_cols.size()==0; }
bool no_sieved_columns() const { return m_ignored_cols.empty(); }
bool no_inner_columns() const { return m_ignored_cols.size()==get_signature().size(); }
relation_base & get_inner() { return *m_inner; }

View file

@ -1216,7 +1216,7 @@ namespace datalog {
verbose_action _va("filter_by_negation");
if (m_cols1.size() == 0) {
if (m_cols1.empty()) {
if (!neg.empty()) {
tgt.reset();
}

View file

@ -72,7 +72,7 @@ namespace datalog {
~sparse_table_plugin() override;
bool can_handle_signature(const table_signature & s) override
{ return s.size()>0; }
{ return !s.empty(); }
table_base * mk_empty(const table_signature & s) override;
sparse_table * mk_clone(const sparse_table & t);

View file

@ -3058,7 +3058,7 @@ expr_ref context::get_ground_sat_answer() const {
ground_fact_conjs.push_back(m.mk_eq(sig_arg, sig_val));
ground_arg_vals.push_back(sig_val);
}
if (ground_fact_conjs.size () > 0) {
if (!ground_fact_conjs.empty()) {
expr_ref ground_fact(m);
ground_fact = mk_and(ground_fact_conjs);
m_pm.formula_o2n(ground_fact, ground_fact, i);

View file

@ -72,7 +72,7 @@ app* iuc_solver::mk_proxy (expr *v)
if (is_uninterp_const(e)) { return to_app(v); }
}
def_manager &def = m_defs.size () > 0 ? m_defs.back () : m_base_defs;
def_manager &def = !m_defs.empty() ? m_defs.back () : m_base_defs;
return def.mk_proxy (v);
}

View file

@ -253,7 +253,7 @@ namespace datalog {
all_selects.push_back(rewrite_select(array, select_ops[i]));
}
}
if(all_selects.size()==0)
if(all_selects.empty())
{
expr_ref_vector dummy_args(m);
dummy_args.push_back(array);

View file

@ -481,7 +481,7 @@ namespace opt {
++j;
}
}
if (r == l_true && m_box_models.size() > 0) {
if (r == l_true && !m_box_models.empty()) {
m_model = m_box_models[0];
}
return r;

View file

@ -684,7 +684,7 @@ namespace nlarith {
void get_coefficients(poly const& p, app*& a, app*& b, app*& c) {
a = b = c = z();
if (p.size() > 0) c = p[0];
if (!p.empty()) c = p[0];
if (p.size() > 1) b = p[1];
if (p.size() > 2) a = p[2];
SASSERT(p.size() <= 3);
@ -1359,7 +1359,7 @@ namespace nlarith {
void quot_rem(poly const& u, poly const& v, poly& q, poly& r, app_ref& lc, unsigned& power) {
lc = v.empty()?num(0):v[v.size()-1];
power = 0;
if (u.size() < v.size() || v.size() == 0) {
if (u.size() < v.size() || v.empty()) {
q.reset();
r.reset();
r.append(u);

View file

@ -387,7 +387,7 @@ namespace qe {
for (row const& r : rows) {
expr_ref_vector ts(m);
expr_ref t(m), s(m), val(m);
if (r.m_vars.size() == 0) {
if (r.m_vars.empty()) {
continue;
}
if (r.m_vars.size() == 1 && r.m_vars[0].m_coeff.is_neg() && r.m_type != opt::t_mod) {

View file

@ -104,7 +104,7 @@ bool array_factory::mk_two_diff_values_for(sort * s) {
bool array_factory::get_some_values(sort * s, expr_ref & v1, expr_ref & v2) {
value_set * set = nullptr;
if (!m_sort2value_set.find(s, set) || set->size() == 0) {
if (!m_sort2value_set.find(s, set) || set->empty()) {
if (!mk_two_diff_values_for(s))
return false;
}

View file

@ -281,7 +281,7 @@ namespace smt {
}
}
if (order == 1) {
if (undef_children.size() == 0) {
if (undef_children.empty()) {
// a bug?
} else if (undef_children.size() == 1) {
undef_child = undef_children[0];

View file

@ -548,7 +548,7 @@ namespace smt {
if (!it->is_dead()) {
row const & r = m_rows[it->m_row_id];
theory_var s = r.get_base_var();
if (is_quasi_base(s) && m_var_occs[s].size() == 0)
if (is_quasi_base(s) && m_var_occs[s].empty())
continue;
if (is_int(v)) {
numeral const & c = r[it->m_row_idx].m_coeff;
@ -574,7 +574,7 @@ namespace smt {
TRACE("move_unconstrained_to_base", tout << "before...\n"; display(tout););
int num = get_num_vars();
for (theory_var v = 0; v < num; v++) {
if (m_var_occs[v].size() == 0 && is_free(v)) {
if (m_var_occs[v].empty() && is_free(v)) {
switch (get_var_kind(v)) {
case QUASI_BASE:
break;

View file

@ -141,7 +141,7 @@ namespace smt {
}
void theory_array_full::set_prop_upward(theory_var v, var_data* d) {
if (m_params.m_array_always_prop_upward || d->m_stores.size() >= 1) {
if (m_params.m_array_always_prop_upward || !d->m_stores.empty()) {
theory_array::set_prop_upward(v, d);
}
else {

View file

@ -125,7 +125,7 @@ namespace smt {
literal mk_eq_lit(expr* l, expr* r);
bool is_standard_order(recfun::vars const& vars) const {
return vars.size() == 0 || vars[vars.size()-1]->get_idx() == 0;
return vars.empty() || vars[vars.size()-1]->get_idx() == 0;
}
protected:
void push_case_expand(case_expansion* e) { m_q_case_expand.push_back(e); }

View file

@ -3570,18 +3570,18 @@ void theory_seq::apply_sort_cnstr(enode* n, sort* s) {
}
void theory_seq::display(std::ostream & out) const {
if (m_eqs.size() == 0 &&
m_nqs.size() == 0 &&
if (m_eqs.empty() &&
m_nqs.empty() &&
m_rep.empty() &&
m_exclude.empty()) {
return;
}
out << "Theory seq\n";
if (m_eqs.size() > 0) {
if (!m_eqs.empty()) {
out << "Equations:\n";
display_equations(out);
}
if (m_nqs.size() > 0) {
if (!m_nqs.empty()) {
display_disequations(out);
}
if (!m_re2aut.empty()) {
@ -3655,7 +3655,7 @@ std::ostream& theory_seq::display_disequation(std::ostream& out, ne const& e) co
for (literal lit : e.lits()) {
out << lit << " ";
}
if (e.lits().size() > 0) {
if (!e.lits().empty()) {
out << "\n";
}
for (unsigned j = 0; j < e.ls().size(); ++j) {

View file

@ -2501,7 +2501,7 @@ namespace smt {
}
}
if (resolvedMap.size() == 0) {
if (resolvedMap.empty()) {
// no simplification possible
return node;
} else {
@ -5452,7 +5452,7 @@ namespace smt {
}
if (implyR) {
if (litems1.size() == 0) {
if (litems1.empty()) {
assert_axiom(implyR);
} else {
assert_implication(mk_and(litems1), implyR);
@ -7020,7 +7020,7 @@ namespace smt {
bool theory_str::refine_automaton_lower_bound(eautomaton * aut, rational current_lower_bound, rational & refined_lower_bound) {
ENSURE(aut != nullptr);
if (aut->final_states().size() < 1) {
if (aut->final_states().empty()) {
// no solutions at all
refined_lower_bound = rational::minus_one();
return false;
@ -8168,13 +8168,13 @@ namespace smt {
// step 2: Concat == Constant
if (eqc_const_lhs.size() != 0) {
if (!eqc_const_lhs.empty()) {
expr * conStr = *(eqc_const_lhs.begin());
std::set<expr*>::iterator itor2 = eqc_concat_rhs.begin();
for (; itor2 != eqc_concat_rhs.end(); itor2++) {
solve_concat_eq_str(*itor2, conStr);
}
} else if (eqc_const_rhs.size() != 0) {
} else if (!eqc_const_rhs.empty()) {
expr* conStr = *(eqc_const_rhs.begin());
std::set<expr*>::iterator itor1 = eqc_concat_lhs.begin();
for (; itor1 != eqc_concat_lhs.end(); itor1++) {
@ -8250,7 +8250,7 @@ namespace smt {
ast_manager & m = get_manager();
int hasCommon = 0;
if (eqc_concat_lhs.size() != 0 && eqc_concat_rhs.size() != 0) {
if (!eqc_concat_lhs.empty() && !eqc_concat_rhs.empty()) {
std::set<expr*>::iterator itor1 = eqc_concat_lhs.begin();
std::set<expr*>::iterator itor2 = eqc_concat_rhs.begin();
for (; itor1 != eqc_concat_lhs.end(); itor1++) {
@ -8570,13 +8570,13 @@ namespace smt {
obj_map<expr, std::stack<T_cut *> >::iterator varItor = cut_var_map.begin();
while (varItor != cut_var_map.end()) {
std::stack<T_cut*> & val = cut_var_map[varItor->m_key];
while ((val.size() > 0) && (val.top()->level != 0) && (val.top()->level >= sLevel)) {
while ((!val.empty()) && (val.top()->level != 0) && (val.top()->level >= sLevel)) {
// TRACE("str", tout << "remove cut info for " << mk_pp(e, get_manager()) << std::endl; print_cut_var(e, tout););
// T_cut * aCut = val.top();
val.pop();
// dealloc(aCut);
}
if (val.size() == 0) {
if (val.empty()) {
cutvarmap_removes.insert(varItor->m_key);
}
varItor++;
@ -9402,7 +9402,7 @@ namespace smt {
}
}
if (depMap.size() == 0) {
if (depMap.empty()) {
std::map<expr*, int>::iterator itor = strVarMap.begin();
for (; itor != strVarMap.end(); itor++) {
expr * var = get_alias_index_ast(aliasIndexMap, itor->first);
@ -10801,7 +10801,7 @@ namespace smt {
expr * var = fvIt2->first;
tmpSet.clear();
get_eqc_allUnroll(var, constValue, tmpSet);
if (tmpSet.size() > 0) {
if (!tmpSet.empty()) {
fv_unrolls_map[var] = tmpSet;
}
}
@ -10935,7 +10935,7 @@ namespace smt {
expr * var = fvIt1->first;
fSimpUnroll.clear();
get_eqc_simpleUnroll(var, constValue, fSimpUnroll);
if (fSimpUnroll.size() == 0) {
if (fSimpUnroll.empty()) {
gen_assign_unroll_reg(fv_unrolls_map[var]);
} else {
expr * toAssert = gen_assign_unroll_Str2Reg(var, fSimpUnroll);
@ -11548,7 +11548,7 @@ namespace smt {
unroll_tries_map[var][unrolls].erase(e);
}
if (unroll_tries_map[var][unrolls].size() == 0) {
if (unroll_tries_map[var][unrolls].empty()) {
unroll_tries_map[var][unrolls].push_back(mk_unroll_test_var());
}

View file

@ -618,7 +618,7 @@ namespace smt {
th_var v1 = null_theory_var, v2 = null_theory_var;
bool pos1 = true, pos2 = true;
if (terms.size() >= 1) {
if (!terms.empty()) {
v1 = terms[0].first;
pos1 = terms[0].second.is_one();
SASSERT(v1 != null_theory_var);

View file

@ -170,7 +170,7 @@ lbool tactic2solver::check_sat_core(unsigned num_assumptions, expr * const * ass
break;
default:
m_result->set_status(l_undef);
if (reason_unknown != "")
if (!reason_unknown.empty())
m_result->m_unknown = reason_unknown;
if (num_assumptions == 0 && m_scopes.empty()) {
m_assertions.reset();

View file

@ -74,7 +74,7 @@ struct bv_bound_chk_rewriter_cfg : public default_rewriter_cfg {
bv_bounds bvb(m());
const br_status rv = bvb.rewrite(m_bv_ineq_consistency_test_max, f, num, args, result);
if (rv != BR_FAILED && (m_m.is_false(result) || m_m.is_true(result))) m_stats.m_unsats++;
else if (rv != BR_FAILED && bvb.singletons().size()) m_stats.m_singletons++;
else if (rv != BR_FAILED && !bvb.singletons().empty()) m_stats.m_singletons++;
else if (rv != BR_FAILED && is_app(result) && to_app(result)->get_num_args() < num) m_stats.m_reduces++;
return rv;
}

View file

@ -440,7 +440,7 @@ lbool sls_engine::search() {
// get candidate variables
ptr_vector<func_decl> & to_evaluate = m_tracker.get_unsat_constants(m_assertions);
if (!to_evaluate.size())
if (to_evaluate.empty())
{
res = l_true;
goto bailout;

View file

@ -1003,7 +1003,7 @@ public:
}
ptr_vector<func_decl> & get_unsat_constants_walksat(expr * e) {
if (!e || m_temp_constants.size())
if (!e || !m_temp_constants.empty())
return m_temp_constants;
ptr_vector<func_decl> const & this_decls = m_constants_occ.find(e);
unsigned sz = this_decls.size();

View file

@ -191,7 +191,7 @@ lbool check_sat(tactic & t, goal_ref & g, model_ref & md, labels_vec & labels, p
return l_false;
}
else {
if (models_enabled && r.size() >= 1) {
if (models_enabled && !r.empty()) {
model_converter_ref mc = r[0]->mc();
model_converter2model(m, mc.get(), md);
if (mc)

View file

@ -35,7 +35,7 @@ static void tst1() {
}
else if (op <= 3) {
ENSURE(v1.size() == v2.size());
if (v1.size() > 0) {
if (!v1.empty()) {
bool val = (rand()%2) != 0;
unsigned idx = rand()%v1.size();
ENSURE(v1.get(idx) == v2[idx]);
@ -46,7 +46,7 @@ static void tst1() {
}
else if (op <= 4) {
ENSURE(v1.size() == v2.size());
if (v1.size() > 0) {
if (!v1.empty()) {
unsigned idx = rand()%v1.size();
VERIFY(v1.get(idx) == v2[idx]);
}

View file

@ -102,7 +102,7 @@ static void tst3() {
ENSURE(t.contains(12));
t.erase(12);
t.erase(10);
ENSURE(t.size() == 0);
ENSURE(t.empty());
ENSURE(t.empty());
ENSURE(t.used_slots() == 0);
t.insert(10);

View file

@ -117,7 +117,7 @@ public:
unknown_options.push_back(t);
}
}
if (unknown_options.size()) {
if (!unknown_options.empty()) {
ret = "Unknown options:";
}
for (const auto & unknownOption : unknown_options) {
@ -127,15 +127,15 @@ public:
ret += "\n";
ret += "Usage:\n";
for (auto allowed_option : m_options)
ret += allowed_option.first + " " + (allowed_option.second.size() == 0 ? std::string("") : std::string("/") + allowed_option.second) + std::string("\n");
ret += allowed_option.first + " " + (allowed_option.second.empty() ? std::string("") : std::string("/") + allowed_option.second) + std::string("\n");
for (auto s : m_options_with_after_string) {
ret += s.first + " " + (s.second.size() == 0? " \"option value\"":("\""+ s.second+"\"")) + "\n";
ret += s.first + " " + (s.second.empty()? " \"option value\"":("\""+ s.second+"\"")) + "\n";
}
return ret;
}
void print() {
if (m_used_options.size() == 0 && m_used_options_with_after_string.size() == 0 && m_free_args.size() == 0) {
if (m_used_options.empty() && m_used_options_with_after_string.empty() && m_free_args.empty()) {
std::cout << "no options are given" << std::endl;
return;
}
@ -146,7 +146,7 @@ public:
for (auto & t : m_used_options_with_after_string) {
std::cout << t.first << " " << t.second << std::endl;
}
if (m_free_args.size() > 0) {
if (!m_free_args.empty()) {
std::cout << "free arguments are: " << std::endl;
for (auto & t : m_free_args) {
std::cout << t << " " << std::endl;

View file

@ -1091,7 +1091,7 @@ void lp_solver_test() {
bool get_int_from_args_parser(const char * option, argument_parser & args_parser, unsigned & n) {
std::string s = args_parser.get_option_value(option);
if (s.size() > 0) {
if (!s.empty()) {
n = atoi(s.c_str());
return true;
}
@ -1100,7 +1100,7 @@ bool get_int_from_args_parser(const char * option, argument_parser & args_parser
bool get_double_from_args_parser(const char * option, argument_parser & args_parser, double & n) {
std::string s = args_parser.get_option_value(option);
if (s.size() > 0) {
if (!s.empty()) {
n = atof(s.c_str());
return true;
}
@ -1830,7 +1830,7 @@ std::unordered_map<std::string, double> * get_solution_from_glpsol_output(std::s
return nullptr;
}
auto split = string_split(s, " \t", false);
if (split.size() == 0) {
if (split.empty()) {
return ret;
}
@ -2050,14 +2050,14 @@ void finalize(unsigned ret) {
void get_time_limit_and_max_iters_from_parser(argument_parser & args_parser, unsigned & time_limit, unsigned & max_iters) {
std::string s = args_parser.get_option_value("--max_iters");
if (s.size() > 0) {
if (!s.empty()) {
max_iters = atoi(s.c_str());
} else {
max_iters = 0;
}
std::string time_limit_string = args_parser.get_option_value("--time_limit");
if (time_limit_string.size() > 0) {
if (!time_limit_string.empty()) {
time_limit = atoi(time_limit_string.c_str());
} else {
time_limit = 0;
@ -2156,7 +2156,7 @@ double get_lp_tst_cost(std::string file_name) {
cost_string = str;
}
}
if (cost_string.size() == 0) {
if (cost_string.empty()) {
std::cout << "cannot find the cost line in " << file_name << std::endl;
throw 0;
}
@ -2377,7 +2377,7 @@ std::unordered_map<std::string, lp::mpq> get_solution_map(lp_solver<lp::mpq, lp:
void run_lar_solver(argument_parser & args_parser, lar_solver * solver, mps_reader<lp::mpq, lp::mpq> * reader) {
std::string maxng = args_parser.get_option_value("--maxng");
if (maxng.size() > 0) {
if (!maxng.empty()) {
solver->settings().max_number_of_iterations_with_no_improvements = atoi(maxng.c_str());
}
if (args_parser.option_is_used("-pd")){
@ -2385,7 +2385,7 @@ void run_lar_solver(argument_parser & args_parser, lar_solver * solver, mps_read
}
std::string iter = args_parser.get_option_value("--max_iters");
if (iter.size() > 0) {
if (!iter.empty()) {
solver->settings().max_total_number_of_iterations = atoi(iter.c_str());
}
if (args_parser.option_is_used("--compare_with_primal")){
@ -2470,7 +2470,7 @@ vector<std::string> get_file_names_from_file_list(std::string filelist) {
std::string s = read_line(end, file);
if (end)
break;
if (s.size() == 0)
if (s.empty())
break;
ret.push_back(s);
} while (true);
@ -2480,13 +2480,13 @@ vector<std::string> get_file_names_from_file_list(std::string filelist) {
void test_lar_solver(argument_parser & args_parser) {
std::string file_name = args_parser.get_option_value("--file");
if (file_name.size() > 0) {
if (!file_name.empty()) {
test_lar_on_file(file_name, args_parser);
return;
}
std::string file_list = args_parser.get_option_value("--filelist");
if (file_list.size() > 0) {
if (!file_list.empty()) {
for (const std::string & fn : get_file_names_from_file_list(file_list))
test_lar_on_file(fn, args_parser);
return;
@ -3600,7 +3600,7 @@ void test_lp_local(int argn, char**argv) {
std::string lufile = args_parser.get_option_value("--checklu");
if (lufile.size()) {
if (!lufile.empty()) {
check_lu_from_file(lufile);
return finalize(0);
}
@ -3623,7 +3623,7 @@ void test_lp_local(int argn, char**argv) {
return finalize(0);
}
std::string file_list = args_parser.get_option_value("--filelist");
if (file_list.size() > 0) {
if (!file_list.empty()) {
for (const std::string & fn : get_file_names_from_file_list(file_list))
solve_mps(fn, args_parser);
return finalize(0);
@ -3704,7 +3704,7 @@ void test_lp_local(int argn, char**argv) {
bool dual = args_parser.option_is_used("--dual");
bool solve_for_rational = args_parser.option_is_used("--mpq");
std::string file_name = args_parser.get_option_value("--file");
if (file_name.size() > 0) {
if (!file_name.empty()) {
solve_mps(file_name, args_parser.option_is_used("--min"), max_iters, time_limit, solve_for_rational, dual, args_parser.option_is_used("--compare_with_primal"), args_parser);
ret = 0;
return finalize(ret);

View file

@ -52,7 +52,7 @@ namespace lp {
std::string m_head;
std::vector<lisp_elem> m_elems;
void print() {
if (m_elems.size()) {
if (!m_elems.empty()) {
std::cout << '(';
std::cout << m_head << ' ';
for (auto & el : m_elems)
@ -133,7 +133,7 @@ namespace lp {
lm.m_head = m_line.substr(0, separator);
m_line = m_line.substr(lm.m_head.size());
eat_blanks();
while (m_line.size()) {
while (!m_line.empty()) {
if (m_line[0] == '(') {
lisp_elem el;
fill_nested_elem(el);
@ -152,7 +152,7 @@ namespace lp {
}
void eat_blanks() {
while (m_line.size()) {
while (!m_line.empty()) {
if (m_line[0] == ' ')
m_line = m_line.substr(1);
else
@ -205,7 +205,7 @@ namespace lp {
bool is_integer(std::string & s) {
if (s.size() == 0) return false;
if (s.empty()) return false;
return atoi(s.c_str()) != 0 || isdigit(s.c_str()[0]);
}

View file

@ -41,7 +41,7 @@ static void tst1() {
v1.pop_back();
}
ENSURE(v1.empty());
ENSURE(v1.size() == 0);
ENSURE(v1.empty());
unsigned i = 1000000000;
while (true) {
std::cout << "resize " << i << "\n";

View file

@ -183,7 +183,7 @@ template <typename T, typename X> unsigned core_solver_pretty_printer<T, X>:: ge
}
if (!m_core_solver.use_tableau()) {
w = std::max(w, (unsigned)T_to_string(m_exact_column_norms[column]).size());
if (m_core_solver.m_column_norms.size() > 0)
if (!m_core_solver.m_column_norms.empty())
w = std::max(w, (unsigned)T_to_string(m_core_solver.m_column_norms[column]).size());
}
return w;
@ -339,7 +339,7 @@ template <typename T, typename X> void core_solver_pretty_printer<T, X>::print()
print_lows();
print_upps();
print_exact_norms();
if (m_core_solver.m_column_norms.size() > 0)
if (!m_core_solver.m_column_norms.empty())
print_approx_norms();
m_out << std::endl;
}

View file

@ -81,7 +81,7 @@ void eta_matrix<T, X>::apply_from_right(vector<T> & w) {
}
template <typename T, typename X>
void eta_matrix<T, X>::apply_from_right(indexed_vector<T> & w) {
if (w.m_index.size() == 0)
if (w.m_index.empty())
return;
#ifdef Z3DEBUG
// vector<T> wcopy(w.m_data);

View file

@ -51,7 +51,7 @@ public:
unsigned row_count() const { return m_data.size(); }
unsigned column_count() const { return m_data.size() > 0? m_data[0].size() : 0; }
unsigned column_count() const { return !m_data.empty()? m_data[0].size() : 0; }
class ref_row {
general_matrix& m_matrix;

View file

@ -37,7 +37,7 @@ struct lar_term {
}
bool is_empty() const {
return m_coeffs.size() == 0; // && is_zero(m_v);
return m_coeffs.empty(); // && is_zero(m_v);
}
unsigned size() const { return static_cast<unsigned>(m_coeffs.size()); }

View file

@ -665,7 +665,7 @@ template <typename T, typename X> bool lp_dual_core_solver<T, X>::ratio_test() {
m_flipped_boxed.clear();
int initial_delta_sign = m_delta >= numeric_traits<T>::zero()? 1: -1;
do {
if (m_breakpoint_set.size() == 0) {
if (m_breakpoint_set.empty()) {
set_status_to_tentative_dual_unbounded_or_dual_unbounded();
return false;
}
@ -697,7 +697,7 @@ template <typename T, typename X> void lp_dual_core_solver<T, X>::update_d_and_x
this->m_d[j] -= m_theta_D * this->m_pivot_row[j];
}
this->m_d[m_p] = - m_theta_D;
if (m_flipped_boxed.size() > 0) {
if (!m_flipped_boxed.empty()) {
process_flipped();
update_xb_after_bound_flips();
}

View file

@ -504,7 +504,7 @@ lp_primal_core_solver<T, X>::get_bound_on_variable_and_update_leaving_precisely(
X tt = - (this->m_lower_bounds[j] - this->m_x[j]) / m;
if (numeric_traits<X>::is_neg(tt))
tt = zero_of_type<X>();
if (leavings.size() == 0 || tt < t || (tt == t && m > abs_of_d_of_leaving)) {
if (leavings.empty() || tt < t || (tt == t && m > abs_of_d_of_leaving)) {
t = tt;
abs_of_d_of_leaving = m;
leavings.clear();
@ -524,7 +524,7 @@ lp_primal_core_solver<T, X>::get_bound_on_variable_and_update_leaving_precisely(
X tt = (this->m_upper_bounds[j] - this->m_x[j]) / m;
if (numeric_traits<X>::is_neg(tt))
tt = zero_of_type<X>();
if (leavings.size() == 0 || tt < t || (tt == t && - m > abs_of_d_of_leaving)) {
if (leavings.empty() || tt < t || (tt == t && - m > abs_of_d_of_leaving)) {
t = tt;
abs_of_d_of_leaving = - m;
leavings.clear();

View file

@ -103,7 +103,7 @@ template <typename T, typename X> void lp_solver<T, X>::flip_costs() {
template <typename T, typename X> bool lp_solver<T, X>::problem_is_empty() {
for (auto & c : m_A_values)
if (c.second.size())
if (!c.second.empty())
return false;
return true;
}
@ -387,7 +387,7 @@ template <typename T, typename X> unsigned lp_solver<T, X>::try_to_remove_some_r
return 0;
}
}
if (rows_to_delete.size() > 0) {
if (!rows_to_delete.empty()) {
for (unsigned k : rows_to_delete) {
m_A_values.erase(k);
}

View file

@ -97,7 +97,7 @@ void print_matrix_with_widths(vector<vector<std::string>> & A, vector<unsigned>
void print_string_matrix(vector<vector<std::string>> & A, std::ostream & out, unsigned blanks_in_front) {
vector<unsigned> widths;
if (A.size() > 0)
if (!A.empty())
for (unsigned j = 0; j < A[0].size(); j++) {
widths.push_back(get_width_of_column(j, A));
}

View file

@ -220,7 +220,7 @@ class mps_reader {
*m_message_stream << "cannot read from file" << std::endl;
}
m_line_number++;
if (m_line.size() != 0 && m_line[0] != '*' && !all_white_space())
if (!m_line.empty() && m_line[0] != '*' && !all_white_space())
break;
}
}
@ -514,7 +514,7 @@ class mps_reader {
lp_assert(m_line.size() >= 14);
vector<std::string> bound_string = split_and_trim(m_line.substr(name_offset, m_line.size()));
if (bound_string.size() == 0) {
if (bound_string.empty()) {
set_m_ok_to_false();
(*m_message_stream) << "error at line " << m_line_number << std::endl;
throw m_line;

View file

@ -248,7 +248,7 @@ void square_sparse_matrix<T, X>::put_max_index_to_0(vector<indexed_value<T>> & r
template <typename T, typename X>
void square_sparse_matrix<T, X>::set_max_in_row(vector<indexed_value<T>> & row_vals) {
if (row_vals.size() == 0)
if (row_vals.empty())
return;
T max_val = abs(row_vals[0].m_value);
unsigned max_index = 0;
@ -386,7 +386,7 @@ bool square_sparse_matrix<T, X>::set_row_from_work_vector_and_clean_work_vector_
}
work_vec.m_index.clear();
auto & row_vals = m_rows[i0];
if (row_vals.size() == 0) {
if (row_vals.empty()) {
return false;
}
set_max_in_row(row_vals); // it helps to find larger pivots

View file

@ -381,7 +381,7 @@ char * mpn_manager::to_string(mpn_digit const * a, size_t const lng, char * buf,
div_1(t_numer, t_denom[0], &temp[0]);
div_unnormalize(t_numer, t_denom, d, &rem);
buf[j++] = '0' + rem;
while (temp.size() > 0 && temp.back() == 0)
while (!temp.empty() && temp.back() == 0)
temp.pop_back();
}
buf[j] = 0;