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


C++ NameMap::erase方法代码示例

本文整理汇总了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;
            }
        }
    }
}
开发者ID:bianjinsong,项目名称:osg,代码行数:86,代码来源:Contributors.cpp

示例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();
}
开发者ID:stahta01,项目名称:wxCode_components,代码行数:67,代码来源:arc.cpp


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