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


C++ Stopwatch::unpause方法代码示例

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


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

示例1: failed

TestCase * Grader07::testSpellCheck(std::string filename)
{
  Commands07 cmds07;
  std::vector<std::string> words;
  std::vector<SpellCheckCmd> commands;

  cmds07.readReads("words", words);
  cmds07.loadSpellCheckCommands(filename, commands);

  if(words.size() == 0){
    return failed("cannot read input file #1");
  }

  if(commands.size() == 0){
    return failed("cannot read input file #2");
  }

  Stopwatch watch;
  watch.start();

  ISpellCheck * checker = (ISpellCheck *) createObject("ISpellCheck");
  if(checker == NULL){
    return nullObject("ISpellCheck");
  }

  watch.pause();
  checker->loadDictionary(words);
  watch.unpause();

  for(size_t i = 0; i < commands.size(); ++i){
    SpellCheckCmd cmd = commands[i];
    std::vector<std::string> product_corrections = checker->suggestCorrections(cmd.word);
    watch.pause();
    std::sort(product_corrections.begin(), product_corrections.end());
    if(product_corrections != cmd.corrections){
      return failed("corrections mismatch");
    }
    watch.unpause();
  }

  watch.stop();
  return passed(watch.getTime());
}
开发者ID:suryak,项目名称:Advanced-Data-Structures,代码行数:43,代码来源:Grader07.cpp

示例2: nullObject

TestCase * Grader02::testWorkload4(int len, int order, int merge_count,
	int merge_len){

	std::vector<int> input;
	std::vector<int> sorted;
	createVector(input, sorted, order, len, false);

	Stopwatch watch;
	watch.start();

	IPriorityQueue * queue = (IPriorityQueue *)createObject("IPriorityQueue4");
	if (queue == NULL){
		return nullObject("IPriorityQueue4");
	}

	watch.pause();
	GoldPriorityQueue gold_queue(sorted);

	for (size_t i = 0; i < merge_len; ++i){
		int key = input[i];
		std::string value = randomValue();
		gold_queue.push_back(key, value);

		watch.unpause();
		IKeyValue * key_value = (IKeyValue *)createObject("IKeyValue4");
		if (key_value == NULL){
			return nullObject("IKeyValue4");
		}

		key_value->setKey(key);
		key_value->setValue(value);

		queue->enqueue(key_value);

		int size = queue->size();
		if (size != gold_queue.size()){
			return failed("after enqueue, size is incorrect");
		}

		int user_key = queue->lowestKey();
		IVectorString * user_values = queue->lowestValues();
		gold_queue.iterate();
		int gold_key = gold_queue.lowestKey();
		std::vector<std::string> values = gold_queue.getValues(gold_key);
		watch.pause();

		if (gold_key != user_key){
			return failed("after enqueue, lowest key is incorrect");
		}

		if (valuesEqual(user_values, values) == false){
			return failed("after enqueue, values incorrect");
		}
	}

	for (int i = 1; i < merge_count; ++i){
		watch.unpause();
		IPriorityQueue * queue2 = (IPriorityQueue *)createObject("IPriorityQueue4");
		if (queue == NULL){
			return nullObject("IPriorityQueue4");
		}

		watch.pause();

		for (int j = (i * merge_len); j < ((i + 1) * merge_len); ++j){
			int key = input[j];
			std::string value = randomValue();
			gold_queue.push_back(key, value);

			watch.unpause();
			IKeyValue * key_value = (IKeyValue *)createObject("IKeyValue4");
			if (key_value == NULL){
				return nullObject("IKeyValue4");
			}

			key_value->setKey(key);
			key_value->setValue(value);

			queue2->enqueue(key_value);
			watch.pause();
		}

		watch.unpause();
		queue->merge(queue2);
		watch.pause();

		gold_queue.iterate();

		watch.unpause();
		int user_key = queue->lowestKey();
		IVectorString * user_values = queue->lowestValues();
		watch.pause();

		int gold_key = gold_queue.lowestKey();
		std::vector<std::string> values = gold_queue.getValues(gold_key);

		if (gold_key != user_key){
			return failed("during dequeue, lowest key is incorrect");
		}

//.........这里部分代码省略.........
开发者ID:karthikeyaJ,项目名称:Advanced-Data-Structure-Priority-Queue,代码行数:101,代码来源:Grader02.cpp


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