Paul, I would have thought that a tree set is based on a binary search tree, not a hash table or similar. That is how a hash set is implemented.
TreeSet is based on
TreeMap, which uses a red‑black tree. It doesn't use an array.
Welcome to the Ranch
Mark Sando wrote:. . . `ArrayList` should be the slowest since it's using array sorting . . .
What makes you think that. It is not necessary to sort the List. As Paul said, swapping elements in arrays is fast. We are not familiar with any means of shifting elements, only swapping. Adding elements to an array, or finding those elements by index, runs in constant time (for an ArrayList, amortised constant time). You appear to be adding elements, but I can't see where you are finding the minimum. I would suggest you don't use the milliseconds method, but
this instead. I also suggest your
testing run dummy runs before you start timing so as to allow any optimisations in the JVM to take full effect. You will see that the timings vary greatly between subsequent runs (that is normal when you do this sort of exercise), but the ordering of timings seems to be constant.
If you add elements to a simple binary search tree, adding will run in logarithmic time if they are in random order, but if they are added already sorted, the tree will add all elements either to the right or to the left, and it will degenerate to being a linked list. Adding then degenerates to linear time. A red‑black tree sorts out that problem as it goes, but it takes time to re‑balance the tree. I don't know the exact implementation of
PriorityQueue, but it says that the adding operations run in logarithmic time. Similarly adding to a TreeSet (link above) runs in logarithmic time.
Searching those collections for a minimum value would run in constant time for PriorityQueue, in logarithmic time for a tree set, and in linear time for a list because you would have to traverse the List. So I should expect that an array list would give the fastest performance, and also, is seems that the information was all available in the API documentation.