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

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -