如何将值添加到作为HashMap中值的优先级队列(逆序)?

huangapple 未分类评论46阅读模式
英文:

How to add values to priority queue(reverse order) used as a value in HashMap

问题

如何将值添加到作为HashMap中值使用的优先队列(倒序)

我知道如何声明一个倒序的优先队列,就像下面这样:

PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());

我知道如何将优先队列声明为HashMap中的值,就像下面这样:

Map<Integer, PriorityQueue<Integer>> map = new HashMap<>();

我想知道,在Java中,我是否可以将倒序的优先队列声明为HashMap中的值?

英文:

How to add values to priority queue(reverse order) used as a value in HashMap

I know how to declare a priority in a reverse order using, like below

PriorityQueue&lt;Integer&gt; pq = new PriorityQueue&lt;&gt;(Collections.reverseOrder());

I know how to declare priority queue as a value in a hashmap, like below

Map&lt;Integer,PriorityQueue&lt;Integer&gt;&gt; map = new HashMap&lt;&gt;();

I would like to know, can I declare priority queue in reverseOrder as a value in hashmap in java?

huangapple
  • 本文由 发表于 2020年4月6日 13:09:12
  • 转载请务必保留本文链接:https://java.coder-hub.com/61053285.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定