C
Chris
I have a problem which is quite similar to the problem of
recalculating a spreadsheet.
I have a collection of cells (actually individual objects in my
problem). Some cells contain data, but many are formulas that must be
calculated, so they depend on other cells (which may contain data or
may require calculation themselves). A cell might depend on any number
of other cells, from 0 to all the other cells in the spreadsheet. The
user might accidentally create circular links, so I should detect that
situation.
The calculation time can be relatively long (seconds for some cells),
so I want to do the calculation in a background thread, leaving the UI
responsive. To take advantage of multiple processors, I want to use
multiple threads for the calculation.
A subset of the cells are currently visible, so I would prefer to
calculate that subset, and the cells they depend on, first.
The user can change the value of a cell (either the basic data, or a
formula) -- when they do, we need to restart the calculation. They
might do this in the middle of a previous calculation, at which point
I would like to start over.
I see a couple of ways to do this, but before I start digging into the
design details (and the code), I would like to ask if there are any
design patterns that would apply to this problem. Seems like other
people must have solved this before. If not design patterns, sample
code?, or even a discussion of the problem?
TIA,
Chris
recalculating a spreadsheet.
I have a collection of cells (actually individual objects in my
problem). Some cells contain data, but many are formulas that must be
calculated, so they depend on other cells (which may contain data or
may require calculation themselves). A cell might depend on any number
of other cells, from 0 to all the other cells in the spreadsheet. The
user might accidentally create circular links, so I should detect that
situation.
The calculation time can be relatively long (seconds for some cells),
so I want to do the calculation in a background thread, leaving the UI
responsive. To take advantage of multiple processors, I want to use
multiple threads for the calculation.
A subset of the cells are currently visible, so I would prefer to
calculate that subset, and the cells they depend on, first.
The user can change the value of a cell (either the basic data, or a
formula) -- when they do, we need to restart the calculation. They
might do this in the middle of a previous calculation, at which point
I would like to start over.
I see a couple of ways to do this, but before I start digging into the
design details (and the code), I would like to ask if there are any
design patterns that would apply to this problem. Seems like other
people must have solved this before. If not design patterns, sample
code?, or even a discussion of the problem?
TIA,
Chris