-
Notifications
You must be signed in to change notification settings - Fork 346
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
Add a non-sparse MapMonoid/Semigroup/Group/etc... #450
Comments
Work around now by doing a |
It's also likely slower too I suppose. More allocations of the options. I On Thursday, June 11, 2015, P. Oscar Boykin notifications@github.com
|
I disagree with the use of dense/spare in this context. It's more a matter of determining which keys are valid. Dense and sparse are typically not a functional distinction like that. For example, both dense and sparse vectors will have a size property with the understanding that indices in [0, size) are valid. One could also imagine a 'sparse' Map-like Monoid (or Map Aggregator) which, instead of storing full associative pairs (x, zero) as they occur, stores a separate Set of keys which map to zero along with the Map of keys that map to non-zero. |
Agree with @jnievelt on the terminology being wrong there; "dense" to me means that the keys have a known, finite domain and that storage is pre-allocated for all of them. The |
edit: actually I think @avibryant would be right, if the I guess I'm not entirely sure how all these things get pulled in anyway. |
Oh right, of course. One term that comes to mind, instead of dense, is |
Oh, I see that even |
This comes down to this: is this an infinite sparse vector of (K -> Option[V]) where None values are not stored. Or is it an infinite sparse vector of K -> V where there is a zero value in V that is not stored. I think it is totally convention because each can simulate the other. Monotonic is good, I might go futher: |
Another approach is to wrap the |
deleting is more memory efficient, so i think we'll want to be additive On Mon, Jun 15, 2015 at 10:33 AM, Gabriel Gonzalez <notifications@github.com
|
The point of this issue is not just that the But yes, it should be additive. It could easily be that applications depend on assumptions like |
Whether or not you use To see why, you just add
... then The only way to truly fix this issue is to have exactly one identity element or quotient the representation so that the user can only distinguish one identity element. The |
Maybe I'm missing something, but isn't |
@jnievelt That means that
... but the law does not hold when |
Ah, of course you're right. In fact the result is that there are no identity elements, except for degenerate cases like Map[Nothing, Long]. |
@Gabriel439 the laws require a definition of =. If your definition of = includes only looking at non-zero keys, you have no problem, because really you had zero + zero = zero for these cases. |
@johnynek I agree. That's why I believe we should wrap the |
plus(Map("hey" -> 0), Map()) == Map()
which surprises people (that zeros are removed). In many cases, you want this, in many cases you don't.We could change the default, but that might break people, or we could add something like:
to opt in to dense versions of all the objects.
The text was updated successfully, but these errors were encountered: