本文整理汇总了C++中MyMap::getNext方法的典型用法代码示例。如果您正苦于以下问题:C++ MyMap::getNext方法的具体用法?C++ MyMap::getNext怎么用?C++ MyMap::getNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyMap
的用法示例。
在下文中一共展示了MyMap::getNext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNextWord
bool WordBagImpl::getNextWord(string& word, int& count)
{
string key;
int* c = m_token->getNext(key);
if (c == NULL)
return false;
else
{
word = key;
count = *c;
return true;
}
}
示例2: getNextWord
bool WordBagImpl::getNextWord(string& word, int& count)
{
int *getNextVal = m_map.getNext(word);
if (getNextVal == nullptr)
return false;
else
{
count = *getNextVal;
return true;
}
}
示例3: save
bool IndexerImpl::save(string filenameBase)
{
ofstream outfile(filenameBase+".txt");
if ( ! outfile )
{
cerr << "Error: Cannot create data.txt!" << endl;
return false;
}
//Map to store locations to grab from array
MyMap<int, int>* h2pull = new MyMap<int, int>;
//Save size of urlToCount to outfile
outfile << urlToCount->size() << endl;
string word;
vector<point>* value = urlToCount->getFirst(word);
while (value!=NULL)
{
//save word and size of vector
outfile << word << " " << value->size() << endl;
vector<point>::iterator it = value->begin();
while (it!=value->end())
{
int hash = it->m_hash;
outfile << hash << " " << it->m_count << endl;
h2pull->associate(hash%MAX_MAP_SIZE, hash%MAX_MAP_SIZE);
it++;
}
value = urlToCount->getNext(word);
}
//Save size of h2pull (number of elements in array to visit)
outfile << h2pull->size() << endl;
int temp;
int* location = h2pull->getFirst(temp);
while (location!=NULL)
{
int size = idToUrl[temp]->size();
outfile << temp << " " << size <<endl;
int hash;
string* url = idToUrl[temp]->getFirst(hash);
while(url!=NULL)
{
outfile << hash << " "<< *url << endl;
url = idToUrl[temp]->getNext(hash);
}
location = h2pull->getNext(temp);
}
delete h2pull;
return true;
}
示例4: saveMyMap
bool saveMyMap(string filename, MyMap<KeyType, ValueType>& m)
{
// save contents of m to a file
ofstream stream("filename"); // Create an ofstream object to create the file
if (! stream) return false; // Return false if we can't create the file
writeItem(stream, m.size()); // Save the number of associations in m to stream
KeyType x;
ValueType* y = m.getFirst(x);
for (int i = 0; i < m.size(); i++) {
writeItem(stream, x);
writeItem(stream, *y);
y = m.getNext(x);
}
return true;
}