Skip to content

Conversation

@m-renaud
Copy link
Collaborator

This function is present in the container's Map interface, this brings more
consistency to the HashMap interface so that it can more easily be used as a
drop in replacement for Data.Map if desired.

This partially addresses #172.

This function is present in the container's Map interface, this brings more
consistency to the HashMap interface so that it can more easily be used as a
drop in replacement for Data.Map if desired.

This partially addresses haskell-unordered-containers#172.
@treeowl
Copy link
Collaborator

treeowl commented Jan 24, 2018

Let's start with the most general: alterF. We can think about others later. I suspect the implementation should be similar to the one for IntMap, but you should be sure to calculate the hash only once.

@m-renaud
Copy link
Collaborator Author

Sounds good, it looks like I'm going to have to pull out the go functions for lookup, insert and delete into top level helpers (so that I can pass the computed hash value into them instead of them computing it each time). Does that sound reasonable?

@treeowl
Copy link
Collaborator

treeowl commented Jan 24, 2018 via email

@treeowl
Copy link
Collaborator

treeowl commented Jan 24, 2018 via email

@treeowl
Copy link
Collaborator

treeowl commented Jan 24, 2018 via email

@m-renaud
Copy link
Collaborator Author

we're not adding adjustWithKey

SGTM.

version of lookup that records the key position in case of collision

Sounds reasonable.

insert, knowing that the key is not yet in the map

I don't see how these would allow us to cut out any operations, you'd still need to traverse through the layers of BitmapIndexed and Full until you reach an Empty. Am I missing something?

insert, knowing that the key is in the map without collision

I can see this, you can skip the ky == k check of the Leaf case.

insert, knowing the key is in the map with a particular position in a collision

Yup, makes sense, just jump to the right index in the collision array

delete, knowing the key is in the map without collision

If I'm reading the implementation right, if we know that a key k is in the map without collision then we will reach a Leaf constructor once, and that leaf must contain the key that we're deleting. Is that correct?

delete, knowing the key is in the map in a particular collision location.

Yup, same as for insert, just jump to the right index in the collision array

@treeowl
Copy link
Collaborator

treeowl commented Jan 24, 2018 via email

@m-renaud
Copy link
Collaborator Author

So. Much. Code. Duplication. :P

@treeowl
Copy link
Collaborator

treeowl commented Jan 25, 2018 via email

@treeowl
Copy link
Collaborator

treeowl commented Feb 8, 2018

Not adding adjustWithKey; alterF was added in #181.

@treeowl treeowl closed this Feb 8, 2018
@phadej phadej mentioned this pull request May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants