Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider a copy-on-write version of Grid for performance #22

Open
jkomoros opened this issue Apr 25, 2015 · 1 comment
Open

Consider a copy-on-write version of Grid for performance #22

jkomoros opened this issue Apr 25, 2015 · 1 comment

Comments

@jkomoros
Copy link
Owner

* This is hard.
* Grids can have parents. If they do, they are a "sparse grid".
    * No, should be a SparseGrid with a *Grid member.
    * SparseGrid has a Cell() method that looks in its cache. if it doesn't exist, looks to parent for one.
* SparseCell is soemthing that looks like a cell but actually is a wrapper around one with a pointer back to the sparseGrid it's from.
    * Sparsecells have their own trapping of any modifiying calls that then call back to the sparseGrid (they know which it is) with the new cell itself to put in the cache. Then the SparseCell can be thrown away.
* Simplest (no caching): Whenever you want a cell, you call grid.Cell(), which sees if it has one, otherwise returns one from another cell.
@jkomoros
Copy link
Owner Author

  • An alternate version of a sparseGrid that's must easier is a grid that is immutable, and when you make a new change it returns a new grid. Even this is hard; impossible counts will change quite a bit even if only one number is put in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant