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


C++ KeyType::size方法代码示例

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


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

示例1: isUniqueWithoutMissingIntegers

bool StringCipherWithPermutationKey::isUniqueWithoutMissingIntegers(const KeyType &key)
{
    const uint32_t key_len = key.size();
    const std::set<int32_t> sorted_key(key.begin(), key.end());
    if (key_len != sorted_key.size())
    {
        return false;
    }

    // Check if all integers are between 0 and the size of the key.
    const uint32_t max_int = *std::max_element(sorted_key.begin(), sorted_key.end());
    if (max_int >= key_len)
    {
        return false;
    }

    return true;
}
开发者ID:glapointe7,项目名称:CryptoGL,代码行数:18,代码来源:StringCipherWithPermutationKey.cpp

示例2: main

int main()
{
    Library article;
    ElementType fileData;
    KeyType keyData;
    bool showMenu = true;

    // Open file of name "fileName"; return an error and exit the program upon
    // failure
    ifstream file;
    char fileName[15] = "cacmpubs10.txt";
    file.open(fileName);

    cout << "\n$ cacmLibrary " << fileName << endl;

    if (file.fail())
    {
        cout << "The file \"" << fileName << "\" failed to open.\n\n";
        exit(1);
    }
    else
        cout << "Loading library, please wait..." << endl;

    // Continues reading, storing, and inserting data as long as there are
    // contents left in the file
    while (!file.eof())
    {
        // Reads and stores the article's key
        getline(file, keyData);
        fileData.key = keyData.substr(0, keyData.size()-1);

        // Reads and stores the article's author
        getline(file, fileData.author);

        // Reads and stores the article's title
        getline(file, fileData.title);

        // Checks to make sure the file is not reading a blank line (or keyless
        // article) If valid, inserts the compiled stored data into the linked
        // list
        if (fileData.key != "")
            article.insert(fileData);
    }

    file.clear();
    file.close();

    cout << "Welcome to the CACM Library!\n\n";

    // Continues to show the user a menu of program options until he indicates
    // he would like to exit
    while (showMenu == true)
    {
        char menuChoice = toupper(menu());

        switch (menuChoice)
        {
            case 'F':
                findArticle(article);
                break;
            case 'L':
                cout << article;  //article.display()
                break;
            case 'A':
                addArticle(article);
                break;
            case 'R':
                removeArticle(article);
                break;
            case 'E':
                showMenu = false;
                break;
            default:
                cout << "Invalid Menu Choice -- Please Try Again\n\n";
                break;
         }
    }

    cout << "Thank you for using the CACM Library!\n$\n";

    return 0;
}
开发者ID:jpiercefield,项目名称:CPlusPlus,代码行数:82,代码来源:main1.cpp


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