示例#1
0
void Match()
{
	int currentComplex=0;
	bool ClusterHasMatch;
	//const char* mapping = "EGMPTBFOARDCU";
	
	for(int cluster=0; cluster<numClust; cluster++){
		ClusterHasMatch=false;
		ClusterSMatched[cluster]=false;
		
		for(currentComplex = 0; currentComplex<numberOfComplexes; currentComplex++){
			for(int i=0; i<numVerts; i++){ AlreadyCounted[i]=0; }
			numberMatched[currentComplex]=0;
			ComplexList[currentComplex].RewindToHead();
			for(int i=0; i<ComplexSize[currentComplex]; i++){
				if(whichCluster[ComplexList[currentComplex].CurrentPtr->Data] == cluster){
					numberMatched[currentComplex]++;
				}
				//printf("%d ",numberMatched[currentComplex]);
				ComplexList[currentComplex].Advance();
			}
			if( IsAMatch(cluster, currentComplex, numberMatched[currentComplex]) ){
				printf("Cluster %d matches complex %d %d times. Sizes %d and %d. ",cluster,currentComplex,numberMatched[currentComplex], ClusterSize[cluster], ComplexSize[currentComplex]);
				ClusterHasMatch = true;
				ClusterMatched[cluster]=true;
				ComplexMatched[currentComplex]=true;
				if(ComplexFunction[currentComplex]==ClusterFunction[cluster]){//SUPERMATCH!
					ClusterSMatched[cluster]=true;
					ComplexSMatched[currentComplex]=true;
					printf("Both function %c. (SUPERMATCH)\n",functionMapping[ComplexFunction[currentComplex]]);
				} else {
					printf("Functions %c and %c.\n", functionMapping[ClusterFunction[cluster]], functionMapping[ComplexFunction[currentComplex]]);
				}
				
			}
			
		}
		if(ClusterHasMatch){ NumMatchedClusters++; }
 	}
	NumMatchedComplexes=0;
	for(currentComplex = 0; currentComplex<numberOfComplexes; currentComplex++){
		if(ComplexMatched[currentComplex] && ComplexSize[currentComplex]){
			NumMatchedComplexes++;
		}
	}
}
示例#2
0
//
/// Returns the first registered template whose pattern matches the given file name.
/// If no template is compatible with the supplied file name, or if the template is
/// open already, it returns 0.
///
/// This implementation compares the path's extension with the ';' separated
/// filter lists in each template looking for a case-insensitive match. Allows
/// '?'s in the template filters to match any character in the path's extension
///
/// Example:
///
///   The path: "documents.1995\accounts_receivable.plan"
///
///   Would match the filter: "*.xls;*.wk?;*.plan"
//
TDocTemplate*
TDocManager::MatchTemplate(LPCTSTR path)
{

  // !BB if (FindDocument(path))
  // !BB  return 0;

  // Iterate through templates
  //
  for (TDocTemplate* tpl = TemplateList; tpl != 0; tpl = tpl->GetNextTemplate()) {

    // Skip hidden templates or templates without filters specified
    //
    LPCTSTR tplFilter = tpl->GetFileFilter();
    if (!tplFilter || tpl->IsFlagSet(dtHidden))
      continue;

    // Make locale copy of filter
    //
    TAPointer<tchar> fltrCopy(nstrnewdup(tplFilter));
    LPTSTR fltr = fltrCopy;
    LPTSTR nxtFltr;

    // For each template, try each wilcard specified
    //
    while (fltr) {

      // Is there another wildcard following - Null terminate at ';'
      //
      nxtFltr = _tcschr(fltr, _T(';'));
      if (nxtFltr)
        *nxtFltr++ = 0;

      if (IsAMatch(path, fltr))
        return tpl;

      // Try next filter
      //
      fltr = (nxtFltr && *nxtFltr) ? nxtFltr : 0;
    }
  }
  return 0;
}