How to implement a multi-index dictionary?

前端 未结 11 1464
孤独总比滥情好
孤独总比滥情好 2020-12-14 00:32

Basically I want something like Dictionary, but not (as I\'ve seen here in other question) with the keys in AND, but in OR. To better explain: I

11条回答
  •  自闭症患者
    2020-12-14 01:27

    I'm going to go out on a limb here and appear stupid, but you could just roll your own Dictionary based on two dictionaries. It wouldn't be too terribly difficult to write (even with locking mechanisms to ensure thread safety). I mean, there's plenty of examples out there where you can use an index or a key to access a collection. (Such as Session)

    Conversely, if your multiple indexes are of the same type, you could just add the same item multiple times.

    Dictionary will support something with a GUID index, as well as a simple name index "Joe" - you have to remember to add the item twice.

提交回复
热议问题