Add function insertLookupWithKey #27

Closed
wants to merge 3 commits into
from

Projects

None yet

2 participants

@basvandijk
Contributor

Hi Johan,

Would you consider adding insertLookupWithKey to unordered-containers?

This function is similar to the equivalently named function in Data.Map and Data.IntMap.

O(min(n,W)). The expression (insertLookupWithKey' f k x map) is a pair where the first element is equal to (lookup k map) and the second element equal to (insertWith' (f k) k x map).

insertLookupWithKey :: (Eq k, Hashable k)
                    => (k -> v -> v -> v) -> k -> v -> HashMap k v
                    -> (Maybe v, HashMap k v)
@basvandijk basvandijk Added function insertLookupWithKey
This function is similar to the equivalently named function in
Data.Map and Data.IntMap.

O(min(n,W)). The expression (insertLookupWithKey' f k x map)
is a pair where the first element is equal to (lookup k map)
and the second element equal to (insertWith' (f k) k x map).

insertLookupWithKey :: (Eq k, Hashable k)
                    => (k -> v -> v -> v) -> k -> v -> HashMap k v
                    -> (Maybe v, HashMap k v)
bda78e1
@basvandijk
Contributor

I just realized I made an error in these functions. I will send a fix tomorrow.

@tibbe
Owner
tibbe commented Feb 22, 2012

I think this function is fine and I'll merge it as soon as a find some time to review the patch. I'm unfortunately svamped at the moment.

@tibbe
Owner
tibbe commented Feb 23, 2012

Could you please rebase these patches on top of the current master branch and then squash them into one commit. It want to avoid having known buggy commits as it'll prevent e.g. git bisect from working efficiently.

@basvandijk
Contributor

No problem. I will do this coming weekend.

@basvandijk
Contributor

I merged the commits in issue #29.

@basvandijk basvandijk closed this Feb 27, 2012
@basvandijk basvandijk reopened this Mar 7, 2012
@basvandijk
Contributor

Reopened as requested

@tibbe
Owner
tibbe commented Sep 5, 2012

I never had time to port this to the new implementation. Sorry about that! If you have time to implement this using the HAMT that would be great. Closing in the meantime.

@tibbe tibbe closed this Sep 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment