通過PriorityQueue類構造大頂堆(最大堆)和小頂堆(最小堆)

概念回顧: 1、大頂堆:頭部爲堆中最大的值 2、小頂堆:頭部爲隊中最小的值 3、PriorityQueue:一個具有優先級的隊列,該優先級使得隊列始終按照自然順序進行排序,隊列的頭部爲最小值。 構造小頂堆: PriorityQueue small=new PriorityQueue<>(); 構造大頂堆: PriorityQueue small=new PriorityQueue<>(Collec
相關文章
相關標籤/搜索