I am trying to understand when to use the two data structures. As far as I have understood the PriorityQueue
is also implemented as a tree as the documentation states that the average time for insert, remove and contains is O(log(n)). The TreeSet
also provides the same time complexity. Plus both of them are unsynchorized implementation. And I can write comparator for them to act like min heap or max heap.
Can some one point out in what conditions I use these two sets?