本文整理汇总了C++中svector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ svector::size方法的具体用法?C++ svector::size怎么用?C++ svector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类svector
的用法示例。
在下文中一共展示了svector::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: intersect
void intersect(const svector<F,V>& y, Op& op) const {
// can't do bounded search with std::map, otherwise we would do double binary search
// these thresholds have not been well optimized
if (m.size() < 0.1*y.size()) {
for (const_iterator xit=m.begin(); xit != m.end(); ++xit) {
const_iterator yit = y.find(xit->first);
if (yit != y.end())
op(xit->first, xit->second, yit->second);
}
} else if (0.1*m.size() > y.size()) {
for (const_iterator yit=y.begin(); yit != y.end(); ++yit) {
const_iterator xit = m.find(yit->first);
if (xit != m.end())
op(yit->first, xit->second, yit->second);
}
} else {
const_iterator xit = m.begin();
const_iterator yit = y.begin();
while (xit != m.end() && yit != y.end()) {
if (xit->first > yit->first) {
++yit;
} else if (xit->first < yit->first) {
++xit;
} else {
op(xit->first, xit->second, yit->second);
++xit; ++yit;
}
}
}
}
示例2: get_assignment
/**
\brief return the complement of variables that are currently assigned.
*/
void theory_wmaxsat::get_assignment(svector<bool>& result) {
result.reset();
if (!m_found_optimal) {
for (unsigned i = 0; i < m_vars.size(); ++i) {
result.push_back(false);
}
}
else {
std::sort(m_cost_save.begin(), m_cost_save.end());
for (unsigned i = 0,j = 0; i < m_vars.size(); ++i) {
if (j < m_cost_save.size() && m_cost_save[j] == static_cast<theory_var>(i)) {
result.push_back(false);
++j;
}
else {
result.push_back(true);
}
}
}
TRACE("opt",
tout << "cost save: ";
for (unsigned i = 0; i < m_cost_save.size(); ++i) {
tout << m_cost_save[i] << " ";
}
tout << "\nvars: ";
for (unsigned i = 0; i < m_vars.size(); ++i) {
tout << mk_pp(m_vars[i].get(), get_manager()) << " ";
}
tout << "\nassignment: ";
for (unsigned i = 0; i < result.size(); ++i) {
tout << result[i] << " ";
}
tout << "\n";);
示例3: sort_core
void sort_core(svector<Numeral> & as, unsigned_vector & xs, numeral_buffer<Numeral, numeral_manager> & buffer) {
std::sort(xs.begin(), xs.end());
unsigned num = as.size();
for (unsigned i = 0; i < num; i++) {
m().swap(as[i], buffer[xs[i]]);
}
}
示例4: sort
void sort(svector<Numeral> & as, unsigned_vector & xs, numeral_buffer<Numeral, numeral_manager> & buffer) {
unsigned num = as.size();
for (unsigned i = 0; i < num; i++) {
m().set(buffer[xs[i]], as[i]);
}
sort_core(as, xs, buffer);
}
示例5: translate
virtual model_converter * translate(ast_translation & translator) {
pb_preproc_model_converter* mc = alloc(pb_preproc_model_converter, translator.to());
for (unsigned i = 0; i < m_const.size(); ++i) {
mc->set_value_p(translator(m_const[i].first), translator(m_const[i].second));
}
return mc;
}
示例6: extract
void extract(unsigned_vector& indices)
{
for (unsigned i = 0; i < m_indices.size(); ++i) {
if (m_indices[i]) {
indices.push_back(i);
}
}
}
示例7:
~Task() {
if (v) {delete v; v=nullptr;}
if (blob) {delete blob; blob=nullptr;}
if (msgs) {
for(int i=0;i<msgs->size();++i)
delete msgs->operator[](i);
delete msgs;
msgs=nullptr;
}
}
示例8: collect_inner_signature
void sieve_relation_plugin::collect_inner_signature(const relation_signature & s,
const svector<bool> & inner_columns, relation_signature & inner_sig) {
SASSERT(inner_columns.size()==s.size());
inner_sig.reset();
unsigned n = s.size();
for(unsigned i=0; i<n; i++) {
if(inner_columns[i]) {
inner_sig.push_back(s[i]);
}
}
}
示例9: display_model
void display_model(std::ostream & out) const {
int sz = m_model.size();
for (int i = 1; i < sz; i++) {
if (m_model[i] == l_true) {
out << i << " ";
}
else if (m_model[i] == l_false) {
out << -i << " ";
}
}
out << "\n";
}
示例10: add_random_ineq
static void add_random_ineq(opt::model_based_opt& mbo,
random_gen& r,
svector<int> const& values,
unsigned max_vars,
unsigned max_coeff) {
unsigned num_vars = values.size();
uint_set used_vars;
vector<var> vars;
int value = 0;
for (unsigned i = 0; i < max_vars; ++i) {
unsigned x = r(num_vars);
if (used_vars.contains(x)) {
continue;
}
used_vars.insert(x);
int coeff = r(max_coeff + 1);
if (coeff == 0) {
continue;
}
unsigned sign = r(2);
coeff = sign == 0 ? coeff : -coeff;
vars.push_back(var(x, rational(coeff)));
value += coeff*values[x];
}
unsigned abs_value = value < 0 ? - value : value;
// value + k <= 0
// k <= - value
// range for k is 2*|value|
// k <= - value - range
opt::ineq_type rel = opt::t_le;
int coeff = 0;
if (r(4) == 0) {
rel = opt::t_eq;
coeff = -value;
}
else {
if (abs_value > 0) {
coeff = -value - r(2*abs_value);
}
else {
coeff = 0;
}
if (coeff != -value && r(3) == 0) {
rel = opt::t_lt;
}
}
mbo.add_constraint(vars, rational(coeff), rel);
}
示例11: operator
void operator()(expr * e)
{
if (is_app(e)) {
func_decl * sym = to_app(e)->get_decl();
unsigned idx;
if (m_parent.try_get_index(sym, idx)) {
SASSERT(idx > 0);
--idx;
if (m_indices.size() <= idx) {
m_indices.resize(idx + 1, false);
}
m_indices[idx] = true;
}
}
}
示例12: sn
static void test_sorting4_r(unsigned i, svector<unsigned>& in) {
if (i == in.size()) {
svector<unsigned> out;
unsigned_ext uext;
sorting_network<unsigned_ext> sn(uext);
sn(in, out);
is_sorted(out);
std::cout << "sorted\n";
}
else {
in[i] = 0;
test_sorting4_r(i+1, in);
in[i] = 1;
test_sorting4_r(i+1, in);
}
}
示例13: execute
virtual void execute(cmd_context & ctx) {
if(m_arg_idx<2) {
throw cmd_exception("at least 2 arguments expected");
}
ensure_domain(ctx);
ast_manager& m = ctx.m();
func_decl_ref pred(
m.mk_func_decl(m_rel_name, m_domain->size(), m_domain->c_ptr(), m.mk_bool_sort()), m);
ctx.insert(pred);
datalog::context& dctx = m_dl_ctx->get_dl_context();
dctx.register_predicate(pred, false);
if(!m_kinds.empty()) {
dctx.set_predicate_representation(pred, m_kinds.size(), m_kinds.c_ptr());
}
m_domain = 0;
}
示例14: extract_inner_columns
void sieve_relation_plugin::extract_inner_columns(const relation_signature & s, relation_plugin & inner,
svector<bool> & inner_columns) {
SASSERT(inner_columns.size()==s.size());
unsigned n = s.size();
relation_signature inner_sig_singleton;
for(unsigned i=0; i<n; i++) {
inner_sig_singleton.reset();
inner_sig_singleton.push_back(s[i]);
inner_columns[i] = inner.can_handle_signature(inner_sig_singleton);
}
#if Z3DEBUG
//we assume that if a relation plugin can handle two sets of columns separetely,
//it can also handle them in one relation
relation_signature inner_sig;
collect_inner_signature(s, inner_columns, inner_sig);
SASSERT(inner.can_handle_signature(inner_sig));
#endif
}
示例15:
join_fn(sieve_relation_plugin & p, const relation_base & r1, const relation_base & r2, unsigned col_cnt,
const unsigned * cols1, const unsigned * cols2, relation_join_fn * inner_join_fun)
: convenient_relation_join_fn(r1.get_signature(), r2.get_signature(), col_cnt, cols1, cols2),
m_plugin(p),
m_inner_join_fun(inner_join_fun) {
bool r1_sieved = r1.get_plugin().is_sieve_relation();
bool r2_sieved = r2.get_plugin().is_sieve_relation();
const sieve_relation * sr1 = r1_sieved ? static_cast<const sieve_relation *>(&r1) : 0;
const sieve_relation * sr2 = r2_sieved ? static_cast<const sieve_relation *>(&r2) : 0;
if(r1_sieved) {
m_result_inner_cols.append(sr1->m_inner_cols);
}
else {
m_result_inner_cols.resize(r1.get_signature().size(), true);
}
if(r2_sieved) {
m_result_inner_cols.append(sr2->m_inner_cols);
}
else {
m_result_inner_cols.resize(m_result_inner_cols.size() + r2.get_signature().size(), true);
}
}