Question

There are some algorithms which need "infinite Data-Structures" like an infinite two-dimensional grid of cells. How is such a problem tackeld? Are they maybe using "pseudo-infinite" structures where just a large amount of data is used? Or is there somehow a "resize" implemented, when capacity is not enough?

I am using a Cellular-Automata Algorithm, which is beeing computed on a 2000 x 2000 grid, but i would like to have the grid infinitely.

Était-ce utile?

La solution

By using lazy evaluation.

Delaying the calculation (or creation) of each item in an infinite data structure until it is needed eliminates the problem of having to create an infinite data set.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top