NArray::~NArray() { const std::vector<NAbstract*>::const_iterator cEnd(_children.end()); for (std::vector<NAbstract*>::iterator cIter(_children.begin()); cIter != cEnd; ++cIter) { delete *cIter; } }
TYPED_TEST_P( ConstantIterator, HostSideNaive ) { bolt::cl::constant_iterator< TypeParam > cIter( 3 ); EXPECT_EQ( 3, *cIter ); EXPECT_EQ( 3, cIter[ 0 ] ); EXPECT_EQ( 3, cIter[ 1 ] ); EXPECT_EQ( 3, cIter[ 100 ] ); }
// print contents of clauses ostream & operator<<(ostream &os, const Clause &c) { #if 0 os << c.terms; #else Set_List_Iterator<Term> cIter(c.terms); for (int first = 1; !cIter.done(); cIter++) { if (first) { first = 0; os << cIter(); } else os << "|| " << cIter(); } #endif return(os); }
// print clause literals ostream & operator<<(ostream &os, const Clause &c) { os << "Type: "; switch (c.type) { case Clause::Positive: os << "Positive"; break; case Clause::Negative: os << "Negative"; break; case Clause::Mixed: os << "Mixed"; break; case Clause::Unknown: os << "Unknown"; break; case Clause::Empty: os << "Empty"; break; default: MustBeTrue(0); break; } os << endl; os << "Clause Depth: " << c.depth << endl; os << "Clause Number: " << c.number << endl; if (c.setOfSupport) os << "Set-of-Support: Yes" << endl; else os << "Set-of-Support: No" << endl; if (c.partOfConclusion) os << "Part-of-Conclusion: Yes" << endl; else os << "Part-of-Conclusion: No" << endl; // os << "Clause: " << c.clause << endl; ClauseIterator cIter(c); for ( ; !cIter.done(); cIter++) { Literal key = cIter.key(); List<Literal> data = cIter.data(); os << "equivalence class key literal: " << key << endl; ListIterator<Literal> dataIter(data); for ( ; !dataIter.done(); dataIter++) { os << "equivalence class data literal: " << dataIter() << endl; } } return(os); }
bool infection::isInfecContactAt(const double& t) { // Returns true if an infectious contact exists at time t set<Contact>::iterator cIter( contacts.begin() ); while( cIter != contacts.end() ) { if(cIter->time - t == 0 && cIter->isInfectious()) return true; else cIter++; } return false; }
void NArray::serialize(std::ostringstream& oOutput) const { oOutput << tokens::larray; const std::vector<NAbstract*>::const_iterator cEnd(_children.end()); for (std::vector<NAbstract*>::const_iterator cIter(_children.begin()); cIter != cEnd; ++cIter) { (*cIter)->serialize(oOutput); if (std::distance(cIter, cEnd) != 1) { oOutput << tokens::separator; } } oOutput << tokens::rarray; }
bool infection::hasInfecContacts() { // Returns true if one or more potentially // infectious contacts exist in the list set<Contact>::iterator cIter( contacts.begin() ); if(!hasContacts()) return false; while(cIter != contacts.end()) { if(cIter->isInfectious()) return true; cIter++; } return false; }
vector<const Contact*> infection::getInfecContacts() { // Gets all infectious contacts vector<const Contact*> contactList; set<Contact>::iterator cIter( contacts.begin() ); if(!hasContacts()) return contactList; while(cIter != contacts.end()) { if(cIter->isInfectious()) { contactList.push_back(&(*cIter)); } cIter++; } return contactList; }
bool infection::isInfecByWhoAt(const CON_e contactType, const double& t, infection*& myInfection) { // Returns true if the infection time coincides // with a contact time of type contactType set<Contact>::iterator cIter( contacts.begin() ); bool rv( false ); while( cIter != contacts.end() ) { if(fabs(cIter->time - t) <= FP_TOL && cIter->type == contactType && cIter->isInfectious()) { myInfection = cIter->source; rv=true; break; } cIter++; } return rv; }
// create problem directories for each conclusion in a problem int createProblems() { // split conclusions from axioms List<Semantic * > axioms; List<Semantic * > conclusions; ListIterator<Semantic * > ptreesIter(ptrees); for ( ; !ptreesIter.done(); ptreesIter++) { if (!ptreesIter()->getConclusion()) { if (axioms.insertAtEnd(ptreesIter()) != OK) { ERROR("inserting axioms failed.", errno); return(NOTOK); } } else break; } for ( ; !ptreesIter.done(); ptreesIter++) { if (conclusions.insertAtEnd(ptreesIter()) != OK) { ERROR("inserting conclusions failed.", errno); return(NOTOK); } } // write original axioms into a file if (writeexprs("original_axioms", axioms) != OK) return(NOTOK); // write original conclusion into a file if (writeexprs("original_conclusions", conclusions) != OK) return(NOTOK); // create a directory for each conclusion ListIterator<Semantic * > cIter(conclusions); for (int ic = 1; !cIter.done(); cIter++, ic++) { // remove directory if is exists // make directory for current conclusion char axcdir[BUFSIZ]; sprintf(axcdir, "%s/axioms_conclusion%d", problemdir, ic); if (removedir(axcdir) != OK) { ERRORD("failed to remove directory.", axcdir, errno); return(NOTOK); } if (makedir(axcdir) != OK) { ERRORD("failed to make directory.", axcdir, errno); return(NOTOK); } // write axioms and conclusion if (writeaxconcl(axcdir, axioms, *cIter()) != OK) { ERRORD("failed to write axioms/conclusion.", axcdir, errno); return(NOTOK); } } // all done return(OK); }