Any implementation of Map, i.e. two keys?

前端 未结 3 1738
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-10 06:58

I need a map that has two keys, e.g.

Map2 _employees;

So that I can

_empl         


        
3条回答
  •  爱一瞬间的悲伤
    2020-12-10 07:12

    I imagine the main key would be empId, so I would build a Map with that as the key, i.e. empId ---> Employee. All other unique attributes (e.g. ssn) would be treated as secondary and will use separate Maps as a lookup table for empId (e.g. ssn ---> empId).

    This implementation makes it easy to add/remove employees, since you only need to change one Map, i.e. empId ---> Employee; the other Maps can be rebuilt only when needed.

提交回复
热议问题