本文整理汇总了C++中NameMap::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ NameMap::erase方法的具体用法?C++ NameMap::erase怎么用?C++ NameMap::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NameMap
的用法示例。
在下文中一共展示了NameMap::erase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readContributors
void readContributors(NameMap& names, const string& file)
{
osgDB::ifstream fin(file.c_str());
Words words;
while(fin)
{
string keyword;
fin >> keyword;
words.push_back(keyword);
}
string blank_string;
for(unsigned int i = 0; i < words.size(); ++i)
{
if (submissionsSequence(words, i))
{
if (i + 2 < words.size() && validName(words[i + 1]))
{
NamePair name = createName(words[i + 1], words[i + 2]);
nameCorrection(name);
if (!name.first.empty()) ++names[name];
i += 2;
}
else if (i + 1 < words.size() && validName(words[i + 1]))
{
NamePair name = createName(words[i + 1], blank_string);
nameCorrection(name);
if (!name.first.empty()) ++names[name];
i += 1;
}
}
else
{
if (words[i] == "robert")
{
++names[NameRobertOsfield];
}
else if (words[i] == "don")
{
++names[NameDonBurns];
}
}
}
// reassign fisrt name entries to their full names entries
if (names.size() > 1)
{
for (NameMap::iterator itr = names.begin(); itr != names.end(); )
{
if (itr->first.second.empty())
{
NameMap::iterator next_itr = itr;
++next_itr;
if (next_itr != names.end() && itr->first.first == next_itr->first.first)
{
next_itr->second += itr->second;
names.erase(itr);
itr = next_itr;
}
else
{
++itr;
}
}
else
{
++itr;
}
}
}
// remove the double entries from Robert's contributions
if (names.size() > 1)
{
for (NameMap::iterator itr = names.begin(); itr != names.end(); ++itr)
{
if (itr->first != NameRobertOsfield && itr->first != NameDonBurns)
{
names[NameRobertOsfield] -= itr->second;
}
}
}
}
示例2: Add
bool ArcApp::Add()
{
// turn m_args into a list of files, i.e. expand wildcards, recurse
// directories and remove duplicates
NameMap files;
MakeFileList(files);
wxInputStreamPtr in(MakeInputStream());
if (!in.get()) return false;
wxOutputStreamPtr out(MakeOutputStream());
if (!out.get()) return false;
wxArchiveInputStreamPtr arc(m_factory->NewStream(*in));
wxArchiveOutputStreamPtr outarc(m_factory->NewStream(*out));
wxArchiveEntryPtr entry(arc->GetNextEntry());
outarc->CopyArchiveMetaData(*arc);
for (;;) {
bool keep;
NameMap::iterator it;
if (!entry.get()) {
if (files.empty())
break;
it = files.begin();
keep = false;
} else {
it = files.find(entry->GetInternalName());
keep = true;
}
if (it != files.end()) {
wxString name = it->second;
files.erase(it);
if (wxDirExists(name)) {
*m_info << "adding " << name.mb_str() << std::endl;
wxDateTime dt(wxFileModificationTime(name));
if (!outarc->PutNextDirEntry(name, dt))
return false;
keep = false;
} else {
wxFFileInputStream file(name);
if (file.Ok()) {
*m_info << "adding " << name.mb_str() << std::endl;
wxDateTime dt(wxFileModificationTime(name));
if (!outarc->PutNextEntry(name, dt, file.GetSize()) ||
!outarc->Write(file) || !file.Eof())
return false;
keep = false;
}
}
}
if (keep)
if (!outarc->CopyEntry(entry.release(), *arc))
return false;
if (entry.get() || keep)
entry.reset(arc->GetNextEntry());
}
in.reset();
return arc->Eof() && outarc->Close() && out->Close();
}