I've been reading up on complexity of HashSet
vs TreeSet
, and everywhere I find topics explaining: "HashSet
is faster because it's O(1) instead of O(log n)." Of course, I know this.
However, that only holds if you're working with very large sets. I, on the other hand, need to work with millions of "small" sets, each containing at most 200 objects, and most far less (below 20). The operations on them are very diverse (creating, adding, removing, membership testing, cloning, ...) and hence I'm puzzled on how to best measure/simulate the difference.
Which of both classes will have the least overhead for such small set sizes? Both in terms of speed and of memory overhead. And what about LinkedHashSet
?