本文整理汇总了C++中ptr_vector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ptr_vector::size方法的具体用法?C++ ptr_vector::size怎么用?C++ ptr_vector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ptr_vector
的用法示例。
在下文中一共展示了ptr_vector::size方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool context::scoped_state::set(ptr_vector<expr> & hard) {
bool eq = hard.size() == m_hard.size();
for (unsigned i = 0; eq && i < hard.size(); ++i) {
eq = hard[i] == m_hard[i].get();
}
m_hard.reset();
m_hard.append(hard.size(), hard.c_ptr());
return !eq;
}
示例2: show_interpolant_and_maybe_check
static void show_interpolant_and_maybe_check(cmd_context & ctx,
ptr_vector<ast> &cnsts,
expr *t,
ptr_vector<ast> &interps,
params_ref &m_params,
bool check)
{
if (m_params.get_bool("som", false))
m_params.set_bool("flat", true);
th_rewriter s(ctx.m(), m_params);
for(unsigned i = 0; i < interps.size(); i++){
expr_ref r(ctx.m());
proof_ref pr(ctx.m());
s(to_expr(interps[i]),r,pr);
ctx.regular_stream() << mk_pp(r.get(), ctx.m()) << std::endl;
#if 0
ast_smt_pp pp(ctx.m());
pp.set_logic(ctx.get_logic().str().c_str());
pp.display_smt2(ctx.regular_stream(), to_expr(interps[i]));
ctx.regular_stream() << std::endl;
#endif
}
s.cleanup();
// verify, for the paranoid...
if(check || interp_params(m_params).check()){
std::ostringstream err;
ast_manager &_m = ctx.m();
// need a solver -- make one here FIXME is this right?
bool proofs_enabled, models_enabled, unsat_core_enabled;
params_ref p;
ctx.params().get_solver_params(_m, p, proofs_enabled, models_enabled, unsat_core_enabled);
scoped_ptr<solver> sp = (ctx.get_solver_factory())(_m, p, false, true, false, ctx.get_logic());
if(iz3check(_m,sp.get(),err,cnsts,t,interps))
ctx.regular_stream() << "correct\n";
else
ctx.regular_stream() << "incorrect: " << err.str().c_str() << "\n";
}
for(unsigned i = 0; i < interps.size(); i++){
ctx.m().dec_ref(interps[i]);
}
interp_params itp_params(m_params);
if(itp_params.profile())
profiling::print(ctx.regular_stream());
}
示例3: saveConfig
/** Write settings to config file. */
void UserConfig::saveConfig()
{
const std::string dir = file_manager->getConfigDir();
if(dir=="")
{
std::cerr << "User config firectory does not exist, cannot save config file!\n";
return;
}
const std::string filename = dir + "/" + m_filename;
std::ofstream configfile;
configfile.open (filename.c_str());
if(!configfile.is_open())
{
std::cerr << "Failed to open " << filename.c_str() << " for writing, user config won't be saved\n";
return;
}
configfile << "<?xml version=\"1.0\"?>\n";
configfile << "<stkconfig version=\"" << CURRENT_CONFIG_VERSION << "\" >\n\n";
const int paramAmount = all_params.size();
for(int i=0; i<paramAmount; i++)
{
//std::cout << "saving parameter " << i << " to file\n";
all_params[i].write(configfile);
}
configfile << "</stkconfig>\n";
configfile.close();
} // saveConfig
示例4: ci
// store equivalence class in VertexInfo for each vertex
static
vector<VertexInfoSet> partitionGraph(ptr_vector<VertexInfo> &infos,
WorkQueue &work_queue, const NGHolder &g,
EquivalenceType eq) {
const size_t num_verts = infos.size();
vector<VertexInfoSet> classes;
unordered_map<ClassInfo, unsigned> classinfomap;
// assume we will have lots of classes, so we don't waste time resizing
// these structures.
classes.reserve(num_verts);
classinfomap.reserve(num_verts);
// get distances from start (or accept) for all vertices
// only one of them is used at a time, never both
vector<NFAVertexDepth> depths;
vector<NFAVertexRevDepth> rdepths;
if (eq == LEFT_EQUIVALENCE) {
calcDepths(g, depths);
} else {
calcDepths(g, rdepths);
}
// partition the graph based on CharReach
for (VertexInfo &vi : infos) {
ClassInfo::ClassDepth depth;
if (eq == LEFT_EQUIVALENCE) {
depth = depths[vi.vert_index];
} else {
depth = rdepths[vi.vert_index];
}
ClassInfo ci(g, vi, depth, eq);
auto ii = classinfomap.find(ci);
if (ii == classinfomap.end()) {
// vertex is in a new equivalence class by itself.
unsigned eq_class = classes.size();
vi.equivalence_class = eq_class;
classes.push_back({&vi});
classinfomap.emplace(move(ci), eq_class);
} else {
// vertex is added to an existing class.
unsigned eq_class = ii->second;
vi.equivalence_class = eq_class;
classes.at(eq_class).insert(&vi);
// we now know that this particular class has more than one
// vertex, so we add it to the work queue
work_queue.push(eq_class);
}
}
DEBUG_PRINTF("partitioned, %zu equivalence classes\n", classes.size());
return classes;
}
示例5: is_well_formed_vars
bool is_well_formed_vars(ptr_vector<sort>& bound, expr* e) {
ptr_vector<expr> todo;
ast_mark mark;
todo.push_back(e);
while (!todo.empty()) {
expr* e = todo.back();
todo.pop_back();
if (mark.is_marked(e)) {
continue;
}
mark.mark(e, true);
if (is_quantifier(e)) {
quantifier* q = to_quantifier(e);
unsigned depth = q->get_num_decls();
bound.append(depth, q->get_decl_sorts());
if (!is_well_formed_vars(bound, q->get_expr())) {
return false;
}
bound.resize(bound.size()-depth);
}
else if (is_app(e)) {
app* a = to_app(e);
for (unsigned i = 0; i < a->get_num_args(); ++i) {
todo.push_back(a->get_arg(i));
}
}
else if (is_var(e)) {
var* v = to_var(e);
unsigned index = v->get_idx();
sort* s = v->get_sort();
SASSERT(index < bound.size());
index = bound.size()-1-index;
if (!bound[index]) {
bound[index] = s;
}
if (bound[index] != s) {
return false;
}
}
else {
UNREACHABLE();
}
}
return true;
}
示例6: match
bool seq_decl_plugin::match(ptr_vector<sort>& binding, sort* s, sort* sP) {
if (s == sP) return true;
unsigned i;
if (is_sort_param(sP, i)) {
if (binding.size() <= i) binding.resize(i+1);
if (binding[i] && (binding[i] != s)) return false;
TRACE("seq_verbose", tout << "setting binding @ " << i << " to " << mk_pp(s, *m_manager) << "\n";);
binding[i] = s;
return true;
}
示例7: find_overload
bool symtable::find_overload(symbol s, ptr_vector<sort> const & dom, func_decl * & d) {
ptr_vector<func_decl>* decls = 0;
d = 0;
if (!m_ids.find(s, decls)) {
SASSERT(!decls);
return false;
}
SASSERT(decls);
for (unsigned i = 0; i < decls->size(); ++i) {
func_decl* decl = (*decls)[i];
if (decl->is_associative() && decl->get_arity() > 0) {
for (unsigned j = 0; j < dom.size(); ++j) {
if (dom[j] != decl->get_domain(0)) {
goto try_next;
}
}
d = decl;
return true;
}
if (decl->get_arity() != dom.size()) {
goto try_next;
}
for (unsigned j = 0; j < decl->get_arity(); ++j) {
if (decl->get_domain(j) != dom[j]) {
goto try_next;
}
}
d = decl;
return true;
try_next:
if (decl->get_family_id() == m_manager.get_basic_family_id() && decl->get_decl_kind() == OP_DISTINCT) {
// we skip type checking for 'distinct'
d = decl;
return true;
}
}
return false;
}
示例8: undo_proxies_in_core
void itp_solver::undo_proxies_in_core (ptr_vector<expr> &r)
{
app_ref e(m);
expr_fast_mark1 bg;
for (unsigned i = 0; i < m_first_assumption; ++i)
{ bg.mark(m_assumptions.get(i)); }
// expand proxies
unsigned j = 0;
for (unsigned i = 0, sz = r.size(); i < sz; ++i) {
// skip background assumptions
if (bg.is_marked(r[i])) { continue; }
// -- undo proxies, but only if they were introduced in check_sat
if (m_is_proxied && is_proxy(r[i], e)) {
SASSERT (m.is_or (e));
r[j] = e->get_arg (1);
} else if (i != j) { r[j] = r[i]; }
j++;
}
r.shrink (j);
}
示例9: main
#include "Util/CK/CK.h"
#include <boost/ptr_container/ptr_vector.hpp>
using boost::ptr_vector;
#include <boost/shared_ptr.hpp>
using boost::shared_ptr;
#include "Util/CDCA_Tracer/CDCA_Tracer.h"
using namespace std;
int main() {
CK_section( "Pointer container (vector) ..............." ) {
ptr_vector<CDCA_Tracer> v;
CK_compare( v.size() , 0 )
CDCA_Tracer *a[3];
const int N= sizeof a / sizeof a[0];
for (int i= 0; i < N; ++i) {
v.push_back(a[i]= new CDCA_Tracer());
}
CK_compare( CDCA_Tracer::getMessages() ,
"created <1>" "\n"
"created <2>" "\n"
"created <3>" "\n" )
CK_compare( v.size() , 3 )
CK_compare( &v.front() , a[0] )
CK_compare( &v.back() , a[2] )
CK_compare( typeid(v.back()) , typeid(CDCA_Tracer))
v.pop_back();
CK_compare( CDCA_Tracer::getMessages() ,
示例10: loadConfig
/** Load configuration values from file. */
bool UserConfig::loadConfig()
{
const std::string filename = file_manager->getConfigDir()+"/"+m_filename;
XMLNode* root = file_manager->createXMLTree(filename);
if(!root || root->getName() != "stkconfig")
{
std::cerr << "Could not read user config file file " << filename.c_str() << std::endl;
if(root) delete root;
return false;
}
// ---- Read config file version
int configFileVersion = CURRENT_CONFIG_VERSION;
if(root->get("version", &configFileVersion) < 1)
{
GUIEngine::showMessage( _("Your config file was malformed, so it was deleted and a new one will be created."), 10.0f);
std::cerr << "Warning, malformed user config file! Contains no version\n";
}
if (configFileVersion < CURRENT_CONFIG_VERSION)
{
// current version (8) is 100% incompatible with other versions (which were lisp)
// so we just delete the old config. in the future, for smaller updates, we can
// add back the code previously there that upgraded the config file to the new
// format instead of overwriting it.
GUIEngine::showMessage( _("Your config file was too old, so it was deleted and a new one will be created."), 10.0f);
printf("Your config file was too old, so it was deleted and a new one will be created.");
delete root;
return false;
} // if configFileVersion<SUPPORTED_CONFIG_VERSION
// ---- Read parameters values (all parameter objects must have been created before this point if
// you want them automatically read from the config file)
const int paramAmount = all_params.size();
for(int i=0; i<paramAmount; i++)
{
all_params[i].findYourDataInAChildOf(root);
}
// ---- Read players
// we create those AFTER other values are being read simply because we have many Player
// nodes that all bear the same name, so the generic loading code won't work here
UserConfigParams::m_all_players.clearAndDeleteAll();
std::vector<XMLNode*> players;
root->getNodes("Player", players);
const int amount = players.size();
for (int i=0; i<amount; i++)
{
//std::string name;
//players[i]->get("name", &name);
UserConfigParams::m_all_players.push_back( new PlayerProfile(players[i]) );
}
// sort players by frequency of use
std::sort (UserConfigParams::m_all_players.contentsVector.begin(),
UserConfigParams::m_all_players.contentsVector.end(), comparePlayers);
delete root;
return true;
} // loadConfig
示例11: reduce
void reduce(proof* pf, proof_ref &out)
{
proof *res = nullptr;
m_todo.reset();
m_todo.push_back(pf);
ptr_buffer<proof> args;
bool dirty = false;
while (!m_todo.empty()) {
proof *p, *tmp, *pp;
unsigned todo_sz;
p = m_todo.back();
if (m_cache.find(p, tmp)) {
res = tmp;
m_todo.pop_back();
continue;
}
dirty = false;
args.reset();
todo_sz = m_todo.size();
for (unsigned i = 0, sz = m.get_num_parents(p); i < sz; ++i) {
pp = m.get_parent(p, i);
if (m_cache.find(pp, tmp)) {
args.push_back(tmp);
dirty = dirty || pp != tmp;
} else {
m_todo.push_back(pp);
}
}
if (todo_sz < m_todo.size()) { continue; }
else { m_todo.pop_back(); }
if (m.is_hypothesis(p)) {
// hyp: replace by a corresponding unit
if (m_units.find(m.get_fact(p), tmp)) {
res = tmp;
} else { res = p; }
}
else if (!dirty) { res = p; }
else if (m.is_lemma(p)) {
//lemma: reduce the premise; remove reduced consequences from conclusion
SASSERT(args.size() == 1);
res = mk_lemma_core(args.get(0), m.get_fact(p));
compute_mark1(res);
} else if (m.is_unit_resolution(p)) {
// unit: reduce units; reduce the first premise; rebuild unit resolution
res = mk_unit_resolution_core(args.size(), args.c_ptr());
compute_mark1(res);
} else {
// other: reduce all premises; reapply
if (m.has_fact(p)) { args.push_back(to_app(m.get_fact(p))); }
SASSERT(p->get_decl()->get_arity() == args.size());
res = m.mk_app(p->get_decl(), args.size(), (expr * const*)args.c_ptr());
m_pinned.push_back(res);
compute_mark1(res);
}
SASSERT(res);
m_cache.insert(p, res);
if (m.has_fact(res) && m.is_false(m.get_fact(res))) { break; }
}
out = res;
}
示例12: alloc
tactic * translate(ast_manager & m) override {
return alloc(sine_tactic, m, m_params);
}
void updt_params(params_ref const & p) override {
}
void collect_param_descrs(param_descrs & r) override {
}
void operator()(goal_ref const & g, goal_ref_buffer& result) override {
TRACE("sine", g->display(tout););
TRACE("sine", tout << g->size(););
ptr_vector<expr> new_forms;
filter_expressions(g, new_forms);
TRACE("sine", tout << new_forms.size(););
g->reset();
for (unsigned i = 0; i < new_forms.size(); i++) {
g->assert_expr(new_forms.get(i), 0, 0);
}
g->inc_depth();
g->updt_prec(goal::OVER);
result.push_back(g.get());
TRACE("sine", result[0]->display(tout););
SASSERT(g->is_well_sorted());
}
void cleanup() override {
}
private:
示例13: iz3pp
void iz3pp(ast_manager &m,
const ptr_vector<expr> &cnsts_vec,
expr *tree,
std::ostream& out) {
unsigned sz = cnsts_vec.size();
expr* const* cnsts = &cnsts_vec[0];
out << "(set-option :produce-interpolants true)\n";
free_func_visitor visitor(m);
expr_mark visited;
bool print_low_level = true; // m_params.print_low_level_smt2();
#define PP(_e_) if (print_low_level) out << mk_smt_pp(_e_, m); else ast_smt2_pp(out, _e_, env);
smt2_pp_environment_dbg env(m);
for (unsigned i = 0; i < sz; ++i) {
expr* e = cnsts[i];
for_each_expr(visitor, visited, e);
}
// name all the constraints
hash_map<expr *, symbol> cnames;
int ctr = 1;
for(unsigned i = 0; i < sz; i++){
symbol nm;
std::ostringstream s;
s << "f!" << (ctr++);
cnames[cnsts[i]] = symbol(s.str().c_str());
}
func_decl_set &funcs = visitor.funcs();
func_decl_set::iterator it = funcs.begin(), end = funcs.end();
obj_hashtable<class sort>& sorts = visitor.sorts();
obj_hashtable<class sort>::iterator sit = sorts.begin(), send = sorts.end();
for (; sit != send; ++sit) {
PP(*sit);
}
for (; it != end; ++it) {
func_decl* f = *it;
if(f->get_family_id() == null_family_id){
PP(f);
out << "\n";
}
}
for (unsigned i = 0; i < sz; ++i) {
out << "(assert ";
expr* r = cnsts[i];
symbol nm = cnames[r];
out << "(! ";
PP(r);
out << " :named ";
if (is_smt2_quoted_symbol(nm)) {
out << mk_smt2_quoted_symbol(nm);
}
else {
out << nm;
}
out << ")";
out << ")\n";
}
out << "(check-sat)\n";
out << "(get-interpolant ";
iz3pp_helper pp(m);
pp.print_tree(pp.cook(tree),cnames,out);
out << ")\n";
}