In this and this posts I describe the framework that I want to develop.
I want to implement a memoization strategy to speeedup some functions execution.
An important feature of this framework should be to "remember" the computed values of past runs: let's suppose we write a program where we execute a word count function f
with the big text t
as input. After we have computed r=f(t)
(where r
is the result), we follow the memoization logic, so we store (t,r)
somewhere, let's say an unordered_map
object um
. After this, the program terminates.
At the next execution of the same program, the expensive execution of f
isn't necessary, since um
contains already (t,r)
, so the value r
is returned.
The problem in all of this is how to "remember" um
state in different executions.
IMPORTANT: Obviously this is an example to make you understand a possible application of this framework, but any memoization application must work as well.
Write a c++ object to file is the only solution for this problem/scenario, or there is an other one?