HashSet vs. List performance

前端 未结 12 2468
小鲜肉
小鲜肉 2020-11-22 09:19

It\'s clear that a search performance of the generic HashSet class is higher than of the generic List class. Just compare the has

12条回答
  •  一向
    一向 (楼主)
    2020-11-22 09:31

    It depends. If the exact answer really matters, do some profiling and find out. If you're sure you'll never have more than a certain number of elements in the set, go with a List. If the number is unbounded, use a HashSet.

提交回复
热议问题