Is there a bidirectional multimap persistent data structure?

前端 未结 2 656
逝去的感伤
逝去的感伤 2021-01-12 13:12

In other words, can we model many to many relationships in a persistent data structure efficiently?


A pair of unidirectional multimaps was suggested. However,

2条回答
  •  别那么骄傲
    2021-01-12 13:34

    Proof by construction: the bimap package for Haskell.

    A Bimap is essentially a bijection between subsets of its two argument types

    And how is it implemented?

    data Bimap a b = MkBimap !(M.Map a b) !(M.Map b a)
    

    As a pair of unidirectional maps.

提交回复
热议问题