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

Clear Sparse Array #118

Open
ColmBhandal opened this issue Jan 20, 2022 · 0 comments
Open

Clear Sparse Array #118

ColmBhandal opened this issue Jan 20, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@ColmBhandal
Copy link
Owner

Requirement

Add functionality to Clear a sparse array of all its used values.

NB: Clearly document how this behaves in the case of an impure (e.g. mutable) index validation function. Probably it makes sense to clear the validation cache, since if someone is clearing the array then it's unlikely those indices are being used again.

Add unit tests e.g. Clear should reset the count to zero.

We may want to also implement a Clear() function that operates on a single value in the sparse array - removing it from the underlying dictionary. Again, care should be taken to clearly document & test how this interacts with the validation cache in the case of an impure function. In this case, probably it doesn't make sense to clear the validation cache because if just one value is cleared, there's a good chance someone will write to it again in future, and so it would be more efficient to have that index cached. In this sense, Clear() of a single value would behave much like the setter i.e. writing that value, in how it interacts with the index validation cache.

Value Proposition

(Description of what value arises from implementing this solution e.g. what problem does it solve)

Design Ideas

This could be implemented in terms of a Clear() function on the underlying curry dictionary. Note: this would likely be a lot more efficient than clearing individual values by removing them one by one- because to clear a curry dictionary we probably just have to remove all of its direct children.

@ColmBhandal ColmBhandal added the enhancement New feature or request label Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant