本文整理汇总了C++中vec::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ vec::clear方法的具体用法?C++ vec::clear怎么用?C++ vec::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec
的用法示例。
在下文中一共展示了vec::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: merge
// Returns FALSE if clause is always satisfied ('out_clause' should not be used).
bool SimpSolver::merge(const Clause& _ps, const Clause& _qs, Var v, vec<Lit>& out_clause)
{
merges++;
out_clause.clear();
bool ps_smallest = _ps.size() < _qs.size();
const Clause& ps = ps_smallest ? _qs : _ps;
const Clause& qs = ps_smallest ? _ps : _qs;
for (int i = 0; i < qs.size(); i++){
if (var(qs[i]) != v){
for (int j = 0; j < ps.size(); j++)
if (var(ps[j]) == var(qs[i])) {
if (ps[j] == ~qs[i])
return false;
else
goto next;
}
out_clause.push(qs[i]);
}
next:;
}
for (int i = 0; i < ps.size(); i++)
if (var(ps[i]) != v)
out_clause.push(ps[i]);
return true;
}
示例2: getFac
void getFac(int n , vec &p, vec &a){
p.clear();
a.clear();
while(n > 1){
int small = n ;
for(int i = 0 ; i < psiz && prime[i] * prime[i] <= n ; ++ i)
if(n % prime[i] == 0){ small = prime[i]; break;}
int cnt = 0;
while(n % small == 0){
cnt ++ ;
n /= small;
}
p.push_back(small);
a.push_back(cnt);
}
}
示例3: analyzeFinal
/*_________________________________________________________________________________________________
|
| analyzeFinal : (p : Lit) -> [void]
|
| Description:
| Specialized analysis procedure to express the final conflict in terms of assumptions.
| Calculates the (possibly empty) set of assumptions that led to the assignment of 'p', and
| stores the result in 'out_conflict'.
|_________________________________[email protected]*/
void MiniSATP::analyzeFinal(Lit p, vec<Lit>& out_conflict)
{
out_conflict.clear();
out_conflict.push(p);
if (decisionLevel() == 0)
return;
seen[var(p)] = 1;
for (int i = trail.size()-1; i >= trail_lim[0]; i--){
Var x = var(trail[i]);
if (seen[x]){
if (reason[x] == NULL){
assert(level[x] > 0);
out_conflict.push(~trail[i]);
}else{
Clause& c = *reason[x];
for (int j = 1; j < c.size(); j++)
if (level[var(c[j])] > 0)
seen[var(c[j])] = 1;
}
seen[x] = 0;
}
}
seen[var(p)] = 0;
}
示例4: buildSorter
static void buildSorter(vec<Formula>& ps, vec<int>& Cs, vec<Formula>& carry , vec<Formula>& out_sorter, PBOptions* options) {
out_sorter.clear();
vec<Formula> Xs;
for (int i = 0; i < ps.size(); i++)
for (int j = 0; j < Cs[i]; j++)
Xs.push(ps[i]);
unarySortAdd(Xs, carry, out_sorter,options->opt_use_shortCuts);
}
示例5: getStaticEdges
static void getStaticEdges(WellFounded* wf, int v, vec<int>& edges) {
edges.clear();
for (int i = 0; i < wf->head_occ_rules[v].size(); i++) {
ConjRule& r = *wf->head_occ_rules[v][i];
for (int j = 0; j < r.sz; j++) {
edges.push(r.body[j]);
}
}
}
示例6: buildSorter
static
void buildSorter(vec<Formula>& ps, vec<int>& Cs, vec<Formula>& out_sorter)
{
out_sorter.clear();
for (int i = 0; i < ps.size(); i++)
for (int j = 0; j < Cs[i]; j++)
out_sorter.push(ps[i]);
oddEvenSort(out_sorter); // (overwrites inputs)
}
示例7: readClause
static void readClause(char*& in, VSolver& S, vec<Lit>& lits) {
int parsed_lit, var;
lits.clear();
for (;;){
parsed_lit = parseInt(in);
if (parsed_lit == 0) break;
var = abs(parsed_lit)-1;
lits.push( (parsed_lit > 0) ? Lit(var) : ~Lit(var) );
}
}
示例8: readClause
static void readClause(B& in, Solver& S, vec<Lit>& lits) {
int parsed_lit, var;
lits.clear();
for (;;){
parsed_lit = parseInt(in);
if (parsed_lit == 0) break;
var = abs(parsed_lit)-1;
while (var >= S.nVars()) S.newVar();
lits.push( (parsed_lit > 0) ? Lit(var) : ~Lit(var) );
}
}
示例9: getDynamicEdges
static void getDynamicEdges(WellFounded* wf, int v, vec<int>& edges) {
edges.clear();
for (int i = 0; i < wf->head_occ_rules[v].size(); i++) {
ConjRule& r = *wf->head_occ_rules[v][i];
if (r.isFalse()) continue;
edges.push(r.body[r.w]);
}
// fprintf(stderr, "%d: ", v);
// for (int i = 0; i < edges.size(); i++) fprintf(stderr, "%d ", edges[i]);
// fprintf(stderr, "\n");
}
示例10: addFromSolver
void XorSubsumer::addFromSolver(vec<XorClause*>& cs)
{
clauseID = 0;
clauses.clear();
XorClause **i = cs.getData();
for (XorClause **end = i + cs.size(); i != end; i++) {
if (i+1 != end) __builtin_prefetch(*(i+1));
linkInClause(**i);
}
cs.clear();
cs.push(NULL); //HACK --to force xor-propagation
}
示例11: clearPropState
void clearPropState() {
in_queue = false;
dead_rules.clear();
if (sat.confl) {
for (int i = 0; i < no_support.size(); i++) {
for ( ; pufhead[i] < no_support[i].size(); pufhead[i]++) {
no_support_bool[no_support[i][pufhead[i]]] = false;
}
no_support[i].clear();
ushead[i] = 0;
pufhead[i] = 0;
}
}
}
示例12: readClauseCnf
static Int readClauseCnf(B& in, mS& S, vec<Lit>& lits,bool wcnf) {
int parsed_lit, var;
Int weight=1;
if(wcnf) weight = parseIntCnf(in);
lits.clear();
for (;;){
parsed_lit = toint(parseIntCnf(in));
if (parsed_lit == 0) break;
var = abs(parsed_lit)-1;
while (var >= S.nVars()) S.newVar();
lits.push( (parsed_lit > 0) ? Lit(var) : ~Lit(var) );
}
return weight;
}
示例13: rippleAdder
void rippleAdder(const vec<Formula>& xs, const vec<Formula>& ys, vec<Formula>& out)
{
Formula c = _0_;
out.clear();
for (int i = 0; i < max(xs.size(),ys.size()); i++){
Formula x = i < xs.size() ? xs[i] : _0_;
Formula y = i < ys.size() ? ys[i] : _0_;
out.push(FAs(x,y,c));
c = FAc(x,y,c);
}
out.push(c);
while (out.last() == _0_)
out.pop();
}
示例14: addFromSolver
void XorSubsumer::addFromSolver(vec<XorClause*>& cs)
{
clauseID = 0;
clauses.clear();
XorClause **i = cs.getData();
for (XorClause **end = i + cs.size(); i != end; i++) {
if (i+1 != end)
__builtin_prefetch(*(i+1), 1, 1);
linkInClause(**i);
if ((*i)->getVarChanged() || (*i)->getStrenghtened())
(*i)->calcXorAbstraction();
}
cs.clear();
cs.push(NULL); //HACK --to force xor-propagation
}
示例15: readClause
/**
@brief Reads in a clause and puts it in lit
@p[out] lits
*/
void DimacsParser::readClause(StreamBuffer& in, vec<Lit>& lits)
{
int32_t parsed_lit;
Var var;
uint32_t len;
lits.clear();
for (;;) {
parsed_lit = parseInt(in, len);
if (parsed_lit == 0) break;
var = abs(parsed_lit)-1;
if (!debugNewVar) {
if (var >= ((uint32_t)1)<<25) {
std::cout << "ERROR! Variable requested is far too large: " << var << std::endl;
exit(-1);
}
while (var >= solver->nVars()) solver->newVar();
}
lits.push( (parsed_lit > 0) ? Lit(var, false) : Lit(var, true) );
}
}