Well the PriorityQueue
is going to itself be dependent on the Comparitor
or the natural ordering of the items for its sorting, likewise the Set
would be dependent on the natural ordering or the Comparitor
function so no I don't think one exists as part of the default Java install...
But you could probably create one pretty easily if speed isn't a worry by simply implementing the interfaces you want, and using their natural backings, etc... aka
MyQueueSet extends PriorityQueue implements Set {
HashSet set;
...
}
Unfortunately Java's java.util.* data-set classes aren't always the easiest to extend without rewriting chunks of their code.
The PriorityQueue
backing is a heap sorted list of elements, so inserting a new element and then doing a contains(e)
test will an O(n) search because sorting is based on the queuing, not on the data value, if you include a HashSet
to support the Set
functionality though, you can improve your lookup time a lot at the expense of maintaining the dataset references twice (remember that Java is pass-by-value and all objects live on the heap). This should improve performance of a large set.