本文整理汇总了C++中WebURL::appendToOutboundList方法的典型用法代码示例。如果您正苦于以下问题:C++ WebURL::appendToOutboundList方法的具体用法?C++ WebURL::appendToOutboundList怎么用?C++ WebURL::appendToOutboundList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebURL
的用法示例。
在下文中一共展示了WebURL::appendToOutboundList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeWebURLs
void initializeWebURLs(unordered_map<long,WebURL>& webURLs, long& totalURLs, string inputFile )
{
double initialPageRankValue = (double)1/totalURLs;
ifstream infile(inputFile,ios::in);
string line, url;
size_t pos;
vector<long> urlArray;
if(!infile.is_open())
{
string s = "Error : Cannot open the input file \"" + inputFile + "\"";
throw s;
}
while(!infile.eof())
{
getline(infile,line);
ltrim(line);
rtrim(line);
urlArray.clear();
if(line.length() > 0)
{
pos = line.find(' ',0);
if(pos > LARGEST_SIZE_T)
{
// It contains only the master URL and no outbound list of URLs
long Webid = atoi(line.c_str());
urlArray.push_back(Webid);
}
else
{
while(pos < LARGEST_SIZE_T)
{
url = line.substr(0,pos);
long Webid = atoi(url.c_str());
urlArray.push_back(Webid);
line = line.substr(pos + 1);
pos = line.find(' ',0);
if(pos > LARGEST_SIZE_T && line.length() >0 )
{
// This is the last url id on the line
url = line;
Webid = atoi(url.c_str());
urlArray.push_back(Webid);
}
}
}
if(urlArray.size() > 0)
{
// Insert the URLs in the Hash Table i.e. unordered_map
vector<long>::iterator it;
long masterURLid;
for ( it=urlArray.begin() ; it < urlArray.end(); it++ )
{
if(webURLs.find(*it) == webURLs.end())
{
WebURL *url = new WebURL((*it),initialPageRankValue);
std::pair<long,WebURL> myURL((*it),*url);
webURLs.insert(myURL); // copy insertion
delete url;
}
if(it == urlArray.begin())
{
masterURLid = *it; // the first Web url id on the line is the master url id
}
else
{
WebURL *url = &webURLs.at(masterURLid);
url->appendToOutboundList((webURLs.find(*it))->second);
}
}
}
}
}
infile.close();
}