java - How to create MinMaxPriorityQueue with nested generic parameters? -
how create minmaxpriorityqueue
nested generic parameters like:
minmaxpriorityqueue<atomiccountholder<e>> sortedheap;
i've tried kinds of variations think of static create()
method, , builder no avail. works with
minmaxpriorityqueue<integer> s = minmaxpriorityqueue. <integer>create();
but not nested generics. clues helpful.
minmaxpriorityqueue.create()
imposes restriction generic type must implement comparable
interface, i.e. there natural ordering of instances of type.
i assume atomiccountholder<e>
not implement comparable
. in case must provide custom comparator
defines ordering of types. example,
minmaxpriorityqueue<atomiccountholder<e>> sortedheap = minmaxpriorityqueue.orderedby(ordering.natural().onresultof(somefunction)).create();
this assumes have function
takes atomiccountholder<e>
, returns comparable
, integer
. assuming e
comparable, write function
takes atomiccountholder<e extends comparable<? super e>>
, returns whatever atomiccountholder
refers to.
what atomiccountholder
btw? atomicinteger
?
Comments
Post a Comment