diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-02-27 17:49:09 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-02-27 17:49:09 +0100 |
| commit | 1768f21de7b75c98c932fcd734218d348b1b0060 (patch) | |
| tree | e517cc9b792f376b211bbd37a496269913d833d5 /Занимательное программирование/5/3_context/context.hpp | |
| parent | 82ae29cb8a59a1e093190d14f8c5097658545a12 (diff) | |
| download | book-exercises-1768f21de7b75c98c932fcd734218d348b1b0060.tar.gz | |
Добавлена третья задача пятой главы
Diffstat (limited to 'Занимательное программирование/5/3_context/context.hpp')
| -rw-r--r-- | Занимательное программирование/5/3_context/context.hpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Занимательное программирование/5/3_context/context.hpp b/Занимательное программирование/5/3_context/context.hpp new file mode 100644 index 0000000..519b601 --- /dev/null +++ b/Занимательное программирование/5/3_context/context.hpp @@ -0,0 +1,27 @@ +#include <list> +#include "utf8.h" +#include <unordered_map> + +struct context_occurrence +{ + unsigned int count{ 1 }; + std::unordered_map<utf8::utfchar32_t, unsigned int> counts; + + explicit context_occurrence(utf8::utfchar32_t character); + void add(utf8::utfchar32_t character); + + std::unordered_map<utf8::utfchar32_t, unsigned int>::iterator begin(); + std::unordered_map<utf8::utfchar32_t, unsigned int>::iterator end(); +}; + +struct context_model +{ + void add(utf8::utfchar32_t character); + + std::unordered_map<std::string, context_occurrence>::iterator begin(); + std::unordered_map<std::string, context_occurrence>::iterator end(); + +private: + std::list<utf8::utfchar32_t> current_context; + std::unordered_map<std::string, context_occurrence> occurrences; +}; |
