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


C++ table::find方法代码示例

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


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

示例1: push

void push(table& t, string key, int val)
{
    if (t.find(key) == t.end())
        t[key] = vector<int>();
    t[key].push_back(val);
}
开发者ID:jamella,项目名称:CVE_DataMining_Research,代码行数:6,代码来源:stats.cpp

示例2: main

 int main() {
    int P, i, j, prev, next;
    char X;
    string right;
    bool complete = false;

    // read in the CFG
    ifstream fin("CFG.txt");
    fin >> P;
    for(i=0; i<P; i++)  {
        fin >> X >> right;
    // if the first symbol on the right side of a production is a terminal,
    // include it in the FIRST set of the variable on the left side of the production.
        if(islower(right[0]))
            FIRST[X - 'A'] |= 1 << (right[0] - 'a');
        else if(productions.find(X) != productions.end())
            productions[X].push_back(right);
        else    {
            vector <string> vec;
            vec.push_back(right);
            productions[X] = vec;
        }
    }
    fin.close();

    // iterate until no more elements can be added to FIRST set of any variable
    while(!complete)    {
        complete = true;
        for(table::iterator it=productions.begin(); it != productions.end(); it++)  {
            prev = next = FIRST[it->first - 'A'];
            for(vector<string>::iterator jt=(it->second).begin(); jt != (it->second).end(); jt++)   {
                for(i=0; i<jt->length(); i++)   {
                    X = (*jt)[i];
                    if(islower(X))  {
                        next |= 1 << (X - 'a'); break;
                    }
                    if((FIRST[X - 'A'] & (1 << 'e' - 'a')) == 0)    {
                        next |= FIRST[X - 'A']; break;
                    } else
                        next |= ~(~FIRST[X - 'A'] | (1 << 'e' - 'a'));
                }
                if(i == jt->length())
                    next |= (1 << 'e' - 'a');
            }
            if(prev != next)    {
                FIRST[it->first - 'A'] = next; complete = false;
            }
        }
    }

    // print out the FIRST set of each variable
    for(i=0; i<26; i++)
        if(FIRST[i])    {
            printf("FIRST(%c) = { ", i + 'A');
            for(j=0; j<26; j++)
                if(FIRST[i] & (1 << j))
                    printf("%c ", j + 'a');
            printf("}\n");
        }

    return 0;
 }
开发者ID:Momoumar,项目名称:blog-codes,代码行数:62,代码来源:FIRST+set+of+each+variable+in+a+CFG.cpp


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