Difference between using PriorityQueue<T extends Priorizable> or <T extends Comparable> [closed]

StackOverflow https://stackoverflow.com/questions/22158335

  •  19-10-2022
  •  | 
  •  

Question

I don't know much about Priorizable. If I want to do a priority queue of integers, I would just compare each entry(compareTo()) to see where I should put the new element, but what does the "Priorizable" mean, is it an interface or what?. And what does it imply, should I implement a method or something ? is Integer a priorizable ?, please help me with this.

Was it helpful?

Solution

I don't know anything about Priorizable, which isn't part of the JDK, but unless it extends Comparable you can't use it with PriorityQueue as shown in your title. If it does extend Comparable, that's the only answer you need to your question.

OTHER TIPS

Where did you find the type Priorizable? This beast is not part of the Java API.

Have you checked the PriorityQueue API to see what it expects? It will tell you that it sorts objects it holds based on their natural ordering which means implements Comparable, or with a Comparator. Nowhere in the PriorityQueue API is there mention of Priorizable.

I wonder if you're talking about a custom type, an interface perhaps that extends Comparable?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top