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


C++ BSTNode::GetValue方法代码示例

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


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

示例1: Insert

void WordIndex::Insert (const Word & word, const URL & url) {
  bool containsWord = Map<Word, OccurrenceSet>::Contains(word);

  if (true == containsWord) {
    // The word is already in this index -- increment occurrence
    OccurrenceSet dummySet;
    MapNode<Word, OccurrenceSet> mapNode(word, dummySet);
    BSTNode< MapNode<Word, OccurrenceSet> >* node = 
      BST< MapNode<Word, OccurrenceSet> >::Find(mapNode);

    Occurrence wrapper(url);
    BSTNode<Occurrence> * oNode = node->GetValue().GetValue().Find(wrapper);

    if (NULL != oNode) {
      // word occurred on a known web page
      oNode->GetValue().increment();
    } else {
      // word has an occurrence on a new web page
      bool wasInserted = node->GetValue().GetValue().Insert(wrapper);
      assert(wasInserted == true);
    }
  } else {
    // We need to add the word to this index
    OccurrenceSet set;
    Occurrence occurrence(url);
    bool wasAdded = set.Insert(occurrence);
    assert(wasAdded == true);

    Map<Word, OccurrenceSet>::Insert(word, set);
  }
}
开发者ID:ericpeterson,项目名称:Web-Crawler,代码行数:31,代码来源:WordIndex.cpp

示例2: addWords

	void Crawler::addWords(BST < Pair < string,int > >* newOccurrences, string url){
		BSTIterator<Pair <string,int> > iter = newOccurrences->Iterator();
		BSTNode<Pair<string,int> > newNode(Pair<string,int>("",-1));
		BSTNode<Word>* oldNode;
		Occurrence occ;
		occ.setURL(url);
		while(iter.hasNext()){
			newNode = iter.next();
			//is either a new node or an old node
			oldNode = words->Insert(Word(newNode.GetValue().getFirst()));
			occ.setOccurrences(newNode.GetValue().getSecond());
			oldNode->GetValue().addOccurrence(occ);
		}
	}
开发者ID:garfieldnate,项目名称:CS240WebCrawler,代码行数:14,代码来源:Crawler.cpp

示例3: Test

bool WordIndex::Test (ostream & os) {
  bool success = true;
  const int PAGES = 3;
  const int WORDS = 30;
  string urlStrs[PAGES] = {
      "http://www.google.com/index.html"
    , "file:///home/file.txt"
    , "http://www.msn.com/sports.html"
  };
  URL urls[PAGES] = {
      URL(urlStrs[0])
    , URL(urlStrs[1])
    , URL(urlStrs[2])
  };
  Word words[WORDS] = {
      "and", "the", "a", "wood", "couch", "potato", "Henry", "the", "a", "and"
    , "a", "house", "dog", "wood", "couch", "frisbee", "green", "then", "why", "how"
    , "a", "a", "yes", "no", "maybe", "Henry", "the", "frisbee", "green", "couch"
  };

  WordIndex wordIndex;

  for (int i = 0; i < PAGES; i++) {
    for (int j = 0; j < WORDS; j++) {
      wordIndex.Insert(words[j], urls[i]);
    }
  }

  OccurrenceSet set = wordIndex.GetValue("a");

  BSTNode<Occurrence>* node = set.Find(Occurrence(urls[1]));
  TEST (NULL != node);

  Occurrence current = node->GetValue();
  TEST(current.getURL().getFullURL() == urls[1].getFullURL());
  TEST(current.getCount() == 5);

  return success;
}
开发者ID:ericpeterson,项目名称:Web-Crawler,代码行数:39,代码来源:WordIndex.cpp


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