Skip to content

Add isSubsetOf #127

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

Closed
rwbarton opened this issue Feb 23, 2016 · 4 comments
Closed

Add isSubsetOf #127

rwbarton opened this issue Feb 23, 2016 · 4 comments

Comments

@rwbarton
Copy link

Data.Set has a fuction isSubsetOf :: Ord a => Set a -> Set a -> Bool. I needed the corresponding function for Data.HashSet, and it should be possible to implement it more efficiently than can be done through the public interface of Data.HashSet currently.

@bjin
Copy link
Contributor

bjin commented Jun 9, 2016

I'm also interested in having a isSubmapOf function for HashMap, just like the one for Map and IntMap. I have a few ideas but not sure which one is the best way to implement it. @tibbe

  1. Implement isSubmapOf recursively over two HashMap, perform case-by-case analysis like current implementation of unionWith. This is complicated to implement and quite error-prone. I also have concern regarding commit df6c50e. What's the current status of the issue in this commit? Is BitmapIndexed guaranteed to have more than 1 and less than full children now?
  2. Implement isSubmapOf like current implementation of (==), transform two HashMap into two lists of Leafs and Collisions with toList' (see df6c50e). The left is linear scanning and case analysis with only Leaf and Collision. The problem with this approach is that in order to run in strictly linear complexity, we need to change the bits in top layer from least-significant to most-significant, this way the keys in the list returned by toList' is sorted in ordinary Word order. This might hurt the performance if the range of hash key is not a full Word.

@kozross
Copy link

kozross commented Apr 13, 2020

I would very much like a subset-testing function too.

@treeowl
Copy link
Collaborator

treeowl commented Apr 14, 2020

Yes, this seems like a good idea. Let's do it the fastest way. I've been wanting to add mergeA for a while; can we do that and use it for this? I don't remember if it has the right shape to do the job efficiently.

@sjakobi
Copy link
Member

sjakobi commented May 29, 2021

isSubsetOf was added in #282 and released in v0.2.12.0.

@sjakobi sjakobi closed this as completed May 29, 2021
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

5 participants