Composite Key Dictionary

后端 未结 9 512
心在旅途
心在旅途 2020-12-02 10:18

I have some objects in List, let\'s say List and MyClass has several properties. I would like to create an index of the list based on 3 properti

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 10:46

    Another solution to the ones already mentioned would be to store some kind of list of all keys generated so far and when a new object is generated you generate it's hashcode (just as a starting point), check if it's already in the list, if it is, then add some random value etc to it until you've got a unique key, then store that key in the object itself and in the list and return that as the key at all times.

提交回复
热议问题