Is a HashMap a proper data structure

前端 未结 2 1345
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-28 17:07

I store in a HashMap 3 types of object.

HashMap>

[\'Lorry\', [list of lorries]]
[\'Sport\', [list of sport\'s cars]]
<         


        
2条回答
  •  伪装坚强ぢ
    2021-01-28 17:49

    A HashMap is the right data structure for the job, but in your case you might consider using two HashMaps: One holding the relation 'Car Type' -> 'Cars of that Type', and a second one for the relation 'ID' -> 'Car with that ID'.

提交回复
热议问题