[9] | 1 | #include "AtomsAndNodes.h" // class's header file |
---|
| 2 | |
---|
| 3 | CVariableVertex::~CVariableVertex() |
---|
| 4 | { |
---|
| 5 | } |
---|
| 6 | |
---|
| 7 | bool CVariableVertex::substituteWatchCl(bool polarity, const ClauseIdT & oldId, const ClauseIdT &newId) |
---|
| 8 | { |
---|
| 9 | for(vector<ClauseIdT>::iterator jt = watchCls[polarity].end()-1;*jt != SENTINEL_CL; jt--) |
---|
| 10 | { |
---|
| 11 | if(*jt == oldId) *jt = newId; |
---|
| 12 | } |
---|
| 13 | return true; |
---|
| 14 | } |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | bool CVariableVertex::substituteBinLink(bool polarity, const LiteralIdT& oldLit, const LiteralIdT& newLit) |
---|
| 18 | { |
---|
| 19 | vector<LiteralIdT>::iterator it; |
---|
| 20 | for(it = binClLinks[polarity].begin(); it != binClLinks[polarity].end(); it++) |
---|
| 21 | { |
---|
| 22 | if(*it == oldLit) {*it = newLit; return true;} |
---|
| 23 | } |
---|
| 24 | return false; |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | bool CVariableVertex::eraseWatchClause(ClauseIdT idCl, bool polarity) |
---|
| 29 | { |
---|
| 30 | vector<ClauseIdT>& theWatchCls = watchCls[polarity]; |
---|
| 31 | vector<ClauseIdT>::iterator it; |
---|
| 32 | |
---|
| 33 | for(it = theWatchCls.begin();it != theWatchCls.end();it++) |
---|
| 34 | { |
---|
| 35 | if(*it == idCl) |
---|
| 36 | { |
---|
| 37 | theWatchCls.erase(it); |
---|
| 38 | return true; |
---|
| 39 | } |
---|
| 40 | } |
---|
| 41 | return false; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | bool CVariableVertex::eraseBinLinkTo(LiteralIdT idLit, bool Linkpolarity) |
---|
| 45 | { |
---|
| 46 | vector<LiteralIdT> &theLinks = getBinLinks(Linkpolarity); |
---|
| 47 | vector<LiteralIdT>::iterator it; |
---|
| 48 | |
---|
| 49 | for(it = theLinks.begin();it != theLinks.end();it++) |
---|
| 50 | { |
---|
| 51 | if(*it == idLit) |
---|
| 52 | { |
---|
| 53 | theLinks.erase(it); |
---|
| 54 | return true; |
---|
| 55 | } |
---|
| 56 | } |
---|
| 57 | return false; |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | bool CVariableVertex::hasBinLinkTo(LiteralIdT idLit,bool pol) const |
---|
| 62 | { |
---|
| 63 | vector<LiteralIdT>::const_iterator it; |
---|
| 64 | |
---|
| 65 | for(it = getBinLinks(pol).begin();*it != SENTINEL_LIT;it++) |
---|
| 66 | { |
---|
| 67 | if(*it == idLit) return true; |
---|
| 68 | } |
---|
| 69 | it++; |
---|
| 70 | for(;*it != SENTINEL_LIT;it++) |
---|
| 71 | { |
---|
| 72 | if(*it == idLit) return true; |
---|
| 73 | } |
---|
| 74 | return false; |
---|
| 75 | } |
---|