当前位置: 首页>>代码示例>>C++>>正文


C++ Matcher::find方法代码示例

本文整理汇总了C++中Matcher::find方法的典型用法代码示例。如果您正苦于以下问题:C++ Matcher::find方法的具体用法?C++ Matcher::find怎么用?C++ Matcher::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matcher的用法示例。


在下文中一共展示了Matcher::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: readPapers

	void readPapers(int papers, Scanner scanIn) {
		int paper;
		for (paper = 1; paper <= papers; paper++) {
			String paperAuthors;

			paperAuthors = scanIn.nextLine();
			#ifdef DEBUG
				printf("paper #%d %s\n", paper, paperAuthors);
			#endif

			Author authors[] = new Author[Author.MAX_PAPER_AUTHORS];
			int authorsIndex = 0;

			Pattern p = Pattern.compile("\\s*(\\S*)[,]\\s*(\\S*)[,:]");
			Matcher m = p.matcher(paperAuthors);
			while (m.find()) {
				String lname = m.group(1);
				String fname = m.group(2);

				if (debug) {
					printf("\t'%s' => '%s', '%s'\n", paperAuthors, lname, fname);
				}

				authors[authorsIndex] = Author.find(fname, lname);
				if (authors[authorsIndex] == null) {
					if (lname.length() == 0 || fname.length() == 0) {
						continue;
					}
					authors[authorsIndex] = new Author(fname, lname);
				}
				authorsIndex++;
			}

			for (int i = 0; i < authorsIndex; i++) {
				for (int j = 0; j < authorsIndex; j++) {
					authors[i].publicouCom(authors[j]);
				}
			}
		}
	}
开发者ID:luis-puhl,项目名称:algoritmos-avancados,代码行数:40,代码来源:main.cpp

示例2: find

void find(string text, string pattern, int expect) {
    Matcher * impl = getImpl(pattern);
    
    clock_t start_time = clock();
    int pos = impl->find(text);
    clock_t end_time = clock();

    printf("pos :%d\texpect : %d\n", pos, expect);


    assert(pos == expect);
   // cout << pattern.size() << endl;
    string out_text = (text.size() <= 100) ? text : "Too Long";
    string out_pattern =(pattern.size() <= 100) ? pattern : "Too Long";

    
    printf("start time : %lu\n", start_time);
    printf("end   time : %lu\n", end_time);

    printf("text          : %s\npattern       : %s\nmatch positon : %d\nexecution time: %lfs\n\n", 
            out_text.c_str(), out_pattern.c_str() , pos, ((double) end_time - start_time) / CLOCKS_PER_SEC);
    delete impl;
}
开发者ID:13307130278,项目名称:codebase,代码行数:23,代码来源:MatcherTest.cpp

示例3: readCases

	int readCases(int names, Scanner *scanIn, Collection<Entry<String, Author>> *theMap,
			Set<Author> *targets) {
		int nameInd;
		for (nameInd = 1; nameInd <= names; nameInd++) {
			String bigname;

			bigname = scanIn.nextLine();
			#ifdef DEBUG
				printf("\tname #%d %s\n", nameInd, bigname);
			#endif

			Pattern p = Pattern.compile("\\s*(\\S*)[,]\\s*(\\S*)");
			Matcher m = p.matcher(bigname);
			if (m.find()) {
				String lname = m.group(1);
				String fname = m.group(2);

				#ifdef DEBUG
					printf("\tmatcher2'%s' => '%s', '%s'\n", bigname, lname, fname);
				#endif

				Author a = Author.find(fname, lname);response

				theMap.add(new MyEntry(bigname, a));
				if (a != null) {
					targets.add(a);
					#ifdef DEBUG
						printf("\tauthor case '%s' is #%d\n", a.lname, targets.size());
					#endif
				}
			} else {
				theMap.add(new Entry<String, Author>(bigname, null));
			}
		}
		return nameInd;
	}
开发者ID:luis-puhl,项目名称:algoritmos-avancados,代码行数:36,代码来源:main.cpp


注:本文中的Matcher::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。