-
Enhancement
-
Resolution: Duplicate
-
P4
-
None
-
8, 9
A DESCRIPTION OF THE REQUEST :
The java.util.PriorityQueue class needs a constructor that takes a Collection<? extends E> and a Comparator<? extends E> that creates an instance containing the elements in the Collection and whose elements are ordered according to the specified comparator.
JUSTIFICATION :
It is important to have a way to initialize a PriorityQueue with a collection and a comparator in O(n) time
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The new constructor's implementation should set the instance comparator field before calling initFromCollection(), even If the input collection is a PriorityQueue or a SortedSet,
ACTUAL -
The developer cannot currently create a PriorityQueue with a collection and a comparator using a constructor.
CUSTOMER SUBMITTED WORKAROUND :
The developer must now construct the PriorityQueue with the required comparator, and then use add() or addAll() to add elements to the PriorityQueue, causing the queue to be reorganized after each addition (addAl()l just interactively calls add())
The java.util.PriorityQueue class needs a constructor that takes a Collection<? extends E> and a Comparator<? extends E> that creates an instance containing the elements in the Collection and whose elements are ordered according to the specified comparator.
JUSTIFICATION :
It is important to have a way to initialize a PriorityQueue with a collection and a comparator in O(n) time
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The new constructor's implementation should set the instance comparator field before calling initFromCollection(), even If the input collection is a PriorityQueue or a SortedSet,
ACTUAL -
The developer cannot currently create a PriorityQueue with a collection and a comparator using a constructor.
CUSTOMER SUBMITTED WORKAROUND :
The developer must now construct the PriorityQueue with the required comparator, and then use add() or addAll() to add elements to the PriorityQueue, causing the queue to be reorganized after each addition (addAl()l just interactively calls add())
- duplicates
-
JDK-6356745 (coll) Add PriorityQueue(Collection, Comparator)
-
- Open
-