Beispiel #1
0
 // In cases when there is no decl stmt, like dep->Call();
 bool VisitDeclRefExpr(DeclRefExpr* DRE) {
   if (isCandidate(DRE->getDecl())) {
     m_ShouldVisitSubTree = true;
     return false; // returning false will abort the in-depth traversal.
   }
   return true;
 }
void VisiblePosition::initDownstream(const Position &pos)
{
    Position deepPos = deepEquivalent(pos);

    if (isCandidate(deepPos)) {
        m_deepPosition = deepPos;
        Position previous = previousVisiblePosition(deepPos);
        if (previous.isNotNull()) {
            Position next = nextVisiblePosition(previous);
            if (next.isNotNull())
                m_deepPosition = next;
        }
    } else {
        Position next = nextVisiblePosition(deepPos);
        if (next.isNotNull()) {
            m_deepPosition = next;
        } else if (isRenderedBR(deepPos.node()) && deepPos.offset() == 1) {
            m_deepPosition = deepPos;
        } else {
            Position previous = previousVisiblePosition(deepPos);
            if (previous.isNotNull())
                m_deepPosition = previous;
        }
    }
}
Beispiel #3
0
void checkTriplesInCol(sudoku* s, int col){
  int y1, y2, y3;
  for (y1=0; y1<9; ++y1){
    for (y2=y1+1; y2<9; ++y2){
      for (y3=y2+1; y3<9; ++y3){
	// combine three cells
	int i1 = getIndex(col, y1);
	int i2 = getIndex(col, y2);
	int i3 = getIndex(col, y3);
	int combi = (s->candidates[i1] | s->candidates[i2] | s->candidates[i3]) & ~1;
	printf ("Testing col %d: %d, %d, %d =>  %d, %d, %d => %d\n", col, y1, y2, y3, s->candidates[i1], s->candidates[i2], s->candidates[i3], combi);
	if (countBits(combi)==3){
	  // "backup fields"
	  int b1, b2, b3;
	  b1 = s->candidates[i1];
	  b2 = s->candidates[i2];
	  b3 = s->candidates[i3];
	  int i;
	  for (i=1; i<=9; ++i){
	    if (isCandidate(i, combi) && s->fields[i1]!=0 && s->fields[i2]!=0 && s->fields[i3]!=0){
	      printf ("Found a triple in col %d: %d, %d, %d => %d\n", col, y1, y2, y3, combi);
	      removeCandidatesInCol(s, y1, col, i);
	    }
	  }
	  s->candidates[i1] = b1;
	  s->candidates[i2] = b2;
	  s->candidates[i3] = b3;
	  printCandidates(s);
	}
      }
    } 
  }
}
Beispiel #4
0
void checkTriplesInRow(sudoku* s, int row){
  int x1, x2, x3;
  for (x1=0; x1<9; ++x1){
    for (x2=x1+1; x2<9; ++x2){
      for (x3=x2+1; x3<9; ++x3){
	// combine three cells
	int i1 = getIndex(x1, row);
	int i2 = getIndex(x2, row);
	int i3 = getIndex(x3, row);
	int combi = (s->candidates[i1] | s->candidates[i2] | s->candidates[i3]) & ~1;
	printf ("Testing row %d: %d, %d, %d =>  %d, %d, %d => %d\n", row, x1, x2, x3, s->candidates[i1], s->candidates[i2], s->candidates[i3], combi);
	if (countBits(combi)==3){
	  // "backup fields"
	  int b1, b2, b3;
	  b1 = s->candidates[i1];
	  b2 = s->candidates[i2];
	  b3 = s->candidates[i3];
	  int i;
	  for (i=1; i<=9; ++i){
	    if (isCandidate(i, combi) && s->fields[i1]!=0 && s->fields[i2]!=0 && s->fields[i3]!=0){
	      printf ("Found a triple in row %d: %d, %d, %d => %d\n", row, x1, x2, x3, combi);
	      removeCandidatesInRow(s, row, x1, i);
	    }
	  }
	  s->candidates[i1] = b1;
	  s->candidates[i2] = b2;
	  s->candidates[i3] = b3;
	  printCandidates(s);
	}
      }
    } 
  }
}
Beispiel #5
0
void checkPairsInRow(sudoku* s, int row){
  int x1, x2;
  for (x1=0; x1<9; ++x1){
    for (x2=x1+1; x2<9; ++x2){
      // combine two cells
      int i1 = getIndex(x1, row);
      int i2 = getIndex(x2, row);
      int combi = (s->candidates[i1] | s->candidates[i2]) & ~1;
      printf ("Testing row %d: %d, %d, =>  %d, %d => %d\n", row, x1, x2, s->candidates[i1], s->candidates[i2], combi);
      if (countBits(combi)==2 && s->fields[i1]==0 && s->fields[i2]==0){
	// "backup fields"
	int b1, b2;
	b1 = s->candidates[i1];
	b2 = s->candidates[i2];
	int i;
	for (i=1; i<=9; ++i){
	  if (isCandidate(i, combi) && s->fields[i1]!=0 && s->fields[i2]!=0){
	    printf ("Found a pair in row %d: %d, %d, => %d\n", row, x1, x2, combi);
	    removeCandidatesInRow(s, row, x1, i);
	  }
	}
	s->candidates[i1] = b1;
	s->candidates[i2] = b2;
	printCandidates(s);
      }
    } 
  }
}
Beispiel #6
0
// gives the next possible candidate, given the currently assigned value
int nextCandidate(int number, int candidate){
  int i;
  for (i=number+1; i<=9; ++i){
    if (isCandidate(i, candidate)){
      return i;
    }
  }
  return -1;
}
Position VisiblePosition::nextVisiblePosition(const Position &pos)
{
    if (pos.isNull() || atEnd(pos))
        return Position();

    Position test = deepEquivalent(pos);
    bool acceptAnyVisiblePosition = !isCandidate(test);

    Position current = test;
    Position downstreamTest = test.downstream(StayInBlock);
    while (!atEnd(current)) {
        current = nextPosition(current);
        if (isCandidate(current) && (acceptAnyVisiblePosition || (downstreamTest != current.downstream(StayInBlock)))) {
            return current;
        }
    }

    return Position();
}
Beispiel #8
0
 bool VisitDeclStmt(DeclStmt* DS) {
   DeclGroupRef DGR = DS->getDeclGroup();
   for (DeclGroupRef::const_iterator I = DGR.begin(), 
          E = DGR.end(); I != E; ++I) {
     if (isCandidate(*I)) {
       m_ShouldVisitSubTree = true;
       return false; // returning false will abort the in-depth traversal.
     }
   }
   return true;
 }
Position VisiblePosition::downstreamDeepEquivalent() const
{
    Position pos = m_deepPosition;

    if (pos.isNull() || atEnd(pos))
        return pos;

    Position downstreamTest = pos.downstream(StayInBlock);

    Position current = pos;
    while (!atEnd(current)) {
        current = nextPosition(current);
        if (isCandidate(current)) {
            if (downstreamTest != current.downstream(StayInBlock))
                break;
            pos = current;
        }
    }

    return pos;
}
/// Uses PoldiIndexKnownCompounds::isCandidate to find all candidates for
/// supplied peak in the candidate peak collections.
std::vector<IndexCandidatePair>
PoldiIndexKnownCompounds::getIndexCandidatePairs(
    const PoldiPeak_sptr &peak,
    const std::vector<PoldiPeakCollection_sptr> &candidateCollections) const {
    std::vector<IndexCandidatePair> indexCandidates;

    for (size_t i = 0; i < candidateCollections.size(); ++i) {
        PoldiPeakCollection_sptr currentCandidateCollection =
            candidateCollections[i];

        size_t peakCount = currentCandidateCollection->peakCount();
        for (size_t p = 0; p < peakCount; ++p) {
            PoldiPeak_sptr currentCandidate = currentCandidateCollection->peak(p);

            if (isCandidate(peak, currentCandidate)) {
                indexCandidates.push_back(
                    IndexCandidatePair(peak, currentCandidate, i));
            }
        }
    }

    return indexCandidates;
}
void VisiblePosition::initUpstream(const Position &pos)
{
    Position deepPos = deepEquivalent(pos);

    if (isCandidate(deepPos)) {
        m_deepPosition = deepPos;
        Position next = nextVisiblePosition(deepPos);
        if (next.isNotNull()) {
            Position previous = previousVisiblePosition(next);
            if (previous.isNotNull())
                m_deepPosition = previous;
        }
    }
    else {
        Position previous = previousVisiblePosition(deepPos);
        if (previous.isNotNull()) {
            m_deepPosition = previous;
        } else {
            Position next = nextVisiblePosition(deepPos);
            if (next.isNotNull())
                m_deepPosition = next;
        }
    }
}
Beispiel #12
0
bool Participant::isInvitee() const
{
	return !isCandidate();
}