class utils::Dictionary — HIRO 0.7.0 documentation

# class utils::Dictionary

## Overview

Enables mapping string keys to string words efficiently. More…

    #include <Dictionary.h>

    class Dictionary {
    public:
        // classes

        class Node;

        // construction

        Dictionary();

        // methods

        void Clear();
        bool IsAvailable(const std::string& key) const;
        void Set(const std::string& key, const std::string& word);
        std::string Get(const std::string& key, const std::string& default_word = "") const;
        bool Remove(const std::string& key);
        std::vector<std::string> GetAllWords() const;
        std::vector<std::string> GetAllWords(const std::string& key_prefix) const;
    };

## Detailed Documentation

Enables mapping string keys to string words efficiently.

### Methods

    void Clear()

Clears whole database of words and keys.

    bool IsAvailable(const std::string& key) const

Checks if there is a word available for a given key.

    void Set(const std::string& key, const std::string& word)

Creates or changes the word of a given key.

    std::string Get(const std::string& key, const std::string& default_word = "") const

Returns a word for a given key. If word for such key does not exists, returns default_word.

    bool Remove(const std::string& key)

Removes word for a given key. Results in true if an existing word was cleared.

    std::vector<std::string> GetAllWords() const

Returns all stored words.

    std::vector<std::string> GetAllWords(const std::string& key_prefix) const

Returns all stored words whose key starts with defined key_prefix.