コード例 #1
0
ファイル: svector.hpp プロジェクト: sameyh8517/relax-decode
  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
0
ファイル: basic_cmds.cpp プロジェクト: sukwon0709/byterun
 virtual void execute(cmd_context & ctx) {
     ctx.regular_stream() << "\"";
     if (m_cmds.empty()) {
         vector<named_cmd> cmds;
         cmd_context::cmd_iterator it  = ctx.begin_cmds();
         cmd_context::cmd_iterator end = ctx.end_cmds();
         for (; it != end; ++it) {
             cmds.push_back(named_cmd((*it).m_key, (*it).m_value));
         }
         // named_cmd_lt is not a total order for commands, but this is irrelevant for Linux x Windows behavior
         std::sort(cmds.begin(), cmds.end(), named_cmd_lt());
         vector<named_cmd>::const_iterator it2  = cmds.begin();
         vector<named_cmd>::const_iterator end2 = cmds.end();
         for (; it2 != end2; ++it2) {
             display_cmd(ctx, it2->first, it2->second);
         }
     }
     else {
         svector<symbol>::const_iterator it  = m_cmds.begin();
         svector<symbol>::const_iterator end = m_cmds.end();
         for (; it != end; ++it) {
             cmd * c = ctx.find_cmd(*it);
             SASSERT(c);
             display_cmd(ctx, *it, c);
         }
     }
     ctx.regular_stream() << "\"\n";
 }
コード例 #3
0
ファイル: params.cpp プロジェクト: greatmazinger/z3
 void display(std::ostream & out, symbol const & k) const {
     svector<params::entry>::const_iterator it  = m_entries.begin();  
     svector<params::entry>::const_iterator end = m_entries.end();
     for (; it != end; ++it) {                                
         if (it->first != k)
             continue;
         switch (it->second.m_kind) {
         case CPK_BOOL:
             out << (it->second.m_bool_value?"true":"false");
             return;
         case CPK_UINT:
             out << it->second.m_uint_value;
             return;
         case CPK_DOUBLE:
             out << it->second.m_double_value;
             return;
         case CPK_NUMERAL:
             out << *(it->second.m_rat_value);
             return;
         case CPK_SYMBOL:
             out << symbol::mk_symbol_from_c_ptr(it->second.m_sym_value);
             return;
         case CPK_STRING:
             out << it->second.m_str_value;
             return;
         default:
             out << "internal";
             return;
         }
     }
     out << "default";
 }
コード例 #4
0
ファイル: params.cpp プロジェクト: greatmazinger/z3
 void display_smt2(std::ostream & out, char const* module, param_descrs& descrs) const {
     svector<params::entry>::const_iterator it  = m_entries.begin();  
     svector<params::entry>::const_iterator end = m_entries.end();
     for (; it != end; ++it) {
         if (!descrs.contains(it->first)) continue;
         out << "(set-option :";
         out << module << ".";        
         out << it->first;
         switch (it->second.m_kind) {
         case CPK_BOOL:
             out << " " << (it->second.m_bool_value?"true":"false");
             break;
         case CPK_UINT:
             out << " " <<it->second.m_uint_value;
             break;
         case CPK_DOUBLE:
             out << " " << it->second.m_double_value;
             break;
         case CPK_NUMERAL:
             out << " " << *(it->second.m_rat_value);
             break;
         case CPK_SYMBOL:
             out << " " << symbol::mk_symbol_from_c_ptr(it->second.m_sym_value);
             break;
         case CPK_STRING:
             out << " " << it->second.m_str_value;
             break;
         default:
             UNREACHABLE();
             break;
         }
         out << ")\n";
     }
 }
コード例 #5
0
ファイル: params.cpp プロジェクト: greatmazinger/z3
 void display(std::ostream & out) const {
     out << "(params";
     svector<params::entry>::const_iterator it  = m_entries.begin();  
     svector<params::entry>::const_iterator end = m_entries.end();
     for (; it != end; ++it) {
         out << " " << it->first;            
         switch (it->second.m_kind) {
         case CPK_BOOL:
             out << " " << (it->second.m_bool_value?"true":"false");
             break;
         case CPK_UINT:
             out << " " <<it->second.m_uint_value;
             break;
         case CPK_DOUBLE:
             out << " " << it->second.m_double_value;
             break;
         case CPK_NUMERAL:
             out << " " << *(it->second.m_rat_value);
             break;
         case CPK_SYMBOL:
             out << " " << symbol::mk_symbol_from_c_ptr(it->second.m_sym_value);
             break;
         case CPK_STRING:
             out << " " << it->second.m_str_value;
             break;
         default:
             UNREACHABLE();
             break;
         }
     }
     out << ")";
 }
コード例 #6
0
ファイル: params.cpp プロジェクト: sukwon0709/byterun
 void validate(param_descrs const & p) const {
     svector<params::entry>::const_iterator it  = m_entries.begin();  
     svector<params::entry>::const_iterator end = m_entries.end();
     for (; it != end; ++it) {                                
         param_kind expected = p.get_kind(it->first);
         if (expected == CPK_INVALID)
             throw default_exception("unknown parameter '%s'", it->first.str().c_str());
         if (it->second.m_kind != expected) 
             throw default_exception("parameter kind mismatch '%s'", it->first.str().c_str());
     }
 }
コード例 #7
0
ファイル: utils.cpp プロジェクト: kindex/Steel
// concat array of string into one string
std::string implode(const char delimiter, const svector<std::string>& elements)
{
	if (elements.empty())
	{
		return "";
	}

	std::string res;
	svector<string>::const_iterator it = elements.begin();
	res = *it;
	it++;
	for(; it != elements.end(); it++)
	{
		res += delimiter;
		res += *it;
	}
	return res;
}
コード例 #8
0
ファイル: params.cpp プロジェクト: greatmazinger/z3
 void validate(param_descrs const & p) {
     svector<params::entry>::iterator it  = m_entries.begin();  
     svector<params::entry>::iterator end = m_entries.end();
     symbol suffix, prefix;
     for (; it != end; ++it) {                                
         param_kind expected = p.get_kind_in_module(it->first);
         if (expected == CPK_INVALID) {
             std::stringstream strm;
             strm << "unknown parameter '" << it->first.str() << "'\n";    
             strm << "Legal parameters are:\n";
             p.display(strm, 2, false, false);
             throw default_exception(strm.str());
         }
         if (it->second.m_kind != expected && 
             !(it->second.m_kind == CPK_UINT && expected == CPK_NUMERAL)) {
             std::stringstream strm;
             strm << "Parameter " << it->first.str() << " was given argument of type ";
             strm << it->second.m_kind << ", expected " << expected;                
             throw default_exception(strm.str());
         }
     }
 }