Добавлена третья задача пятой главы
This commit is contained in:
27
Занимательное программирование/5/3_context/context.hpp
Normal file
27
Занимательное программирование/5/3_context/context.hpp
Normal file
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user