Skip to content

Commit

Permalink
Redid insertWithKey and lookupHM to no longer use BitState, addes str…
Browse files Browse the repository at this point in the history
…ictness ! to Two and One, wrote a bulk insertion.
  • Loading branch information
TimSheard authored and lehins committed Oct 26, 2021
1 parent 728d543 commit 7623d8b
Show file tree
Hide file tree
Showing 2 changed files with 169 additions and 95 deletions.
5 changes: 2 additions & 3 deletions libs/compact-map/src/Data/Compact/HashMap.hs
Expand Up @@ -23,9 +23,8 @@ insert :: k -> v -> HashMap k v -> HashMap k v
insert k v (HashMap m) = HashMap(KM.insert (toKey k) v m)

insertWithKey :: (k -> v -> v -> v) -> k -> v -> HashMap k v -> HashMap k v
insertWithKey combine key v (HashMap m) = HashMap(KM.insertWithKey comb state v m)
where comb k v1 v2 = combine (fromKey k) v1 v2
state = (KM.initBitState (toKey key))
insertWithKey combine key v (HashMap m) = HashMap(KM.insertWithKey comb (toKey key) v m)
where comb k v1 v2 = combine (fromKey k) v1 v2

restrictKeys :: HashMap k v -> Set k -> HashMap k v
restrictKeys (HashMap m) set = HashMap(KM.domainRestrict m (Set.map toKey set))
Expand Down

0 comments on commit 7623d8b

Please sign in to comment.